[Solved] Width 100% is not working in Bootstrap row in CSS

Last Reply 14 days ago By dharmendr

Posted 14 days ago

hi I use bootstrap v4.3.1

and I wrote below codes:

<link href="Css/bootstrap.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="Scripts/bootstrap.min.js"></script>
<body>
    <form id="form1" runat="server">
        <center>
       <div class="d-sm-inline-flex">
            <div class="row">
             <div id="BackHeader"></div>       
          </div>
        </div>
        </center>
    </form>
</body>

and CSS: 

#BackHeader {
    width:100%;
    background-color:#212121;
    height:50px;
}

as you see in Css I define:

width:100%;

becuse I want it will continue at right and left side of the page but when I run page it doesn't show any thing in browser but when I change width:1200px;

it will show <div> in browser why this happen?

it doesn't work for width:100%;

I used it before but on that case I didn't use bootstrap this problem happen when I use bootstrap

Best regards

Neda

You are viewing reply posted by: dharmendr 14 days ago.
Posted 14 days ago
nedash says:
<div id="BackHeader"></div>     

Since your div does not have any content its not displaying.

Once you add some content to it it will visible.

Since you defined width: 100% it automatically adjusted as per the content inside it.

Check below exmple.

HTML

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
    integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
    integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
    integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<center> 
    <div class="d-sm-inline-flex">
        <div class="row">
            <div id="BackHeader">Back Header</div>
        </div>
    </div>
</center>
<style type="text/css">
    #BackHeader {
        width: 100%;
        background-color: #212121;
        height: 50px;
        color: white;
    }
</style>

Demo