How Do I Use Box Sizing Property With Div Elements

admin_img Posted By Bajarangi soft , Posted On 07-11-2020

In CSS The box-sizing property allows us to include the padding and border in an element's total width and height.So today we discuss how to do it.

How Do I Use Box Sizing Property With Div Elements

Complete Code For Using Box Sizing Property With Div Elements

<!DOCTYPE html>
<html>
<head>
    <title>How Do I Use Box Sizing Property With Div Elements</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
</head>

<style>
    body {
        background-color: #800033;
    }

    .div1 {
        width: 300px;
        height: 100px;
        border: 1px solid blue;
        box-sizing: border-box;
    }

    .div2 {
        width: 300px;
        height: 100px;
        padding: 50px;
        border: 1px solid red;
        box-sizing: border-box;
    }
</style>

<body>
<br/><br/>
<div class="container">
    <br>
    <div class="text-center">
        <h1 id="color" style="color: white;">Box Sizing Property With Div Elements</h1>
    </div>
    <br>
    <div class="well">
        <div class="div1">Both divs are the same size now!</div>
        <br>
        <div class="div2">Hooray!</div>
    </div>
</div>
</body>
</html>

Related Post