I have a container of width 1300 px. Inside the container i have other div.
I need to set the inner div width equal to browser window size eg) 1900px.
The content should be responsive to the window size.
My html code is like below:
<div class="container">
<div class="content">Some style goes here </div>
</div>
Css:
.container {
width: 1300px;
}
.content{
width: 100%
}`
Using width, max-width and margin: auto; Then, you can set the margins to auto, to horizontally center the element within its container. The element will take up the specified width, and the remaining space will be split equally between the two margins: This <div> element has a width of 500px, and margin set to auto.
With a fixed width: 1300px;
, you can not have a responsive to the window size
div
As codehorse said, add
.container {
width: 100%;
}
but add
html, body {
height:100%;
width:100%;
margin:0;
padding:0;
}
to you css as width: 100%;
will render correctly if the dimension of the parent elements have been set beforehand!!
working demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With