Here's the problem I have:-
I have one div that is set to a max width of 960px.
The width of the div inside the div is set to 100%, but 100% means a max of 960px
How can I make the div inside the 960px div become 100% of the user's screen, without moving the child div(100%) out of the parent div(960px)?
EDIT FOR FURTHER CLARIFICATION. Here's the structure:-
gParentDiv parentDiv myDiv
I want myDiv to be the same width as gParentDiv, but keep it within parentDiv
I hope you can help
Method 2: We can make the display attribute of the child container to table-row and display attribute of parent container to table, that will take all the height available from the parent div element. To cover all the width, we can make the width of parent div to 100%.
Answer: Set the 100% height for parents too And we all know that the default value of the height property is auto , so if we also set the height of <body> and <html> elements to 100%, the resulting height of the container div becomes equal the 100% height of the browser window.
If you want the child divs to fit the parent size, you should put a margin at least of the size of the child borders on the child divs ( child. margin >= child.
Answer: Use the CSS display Property You can simply use the CSS display property with the value inline-block to make a <div> not larger than its contents (i.e. only expand to as wide as its contents).
You can use the viewport's height and width.
For example, the following class will make the element the size of the viewport.
.fullscreen { width: 100vw; height: 100vh; }
jsFiddle Demo
This is a pure CSS3 solution, but it has some browser support issues.
If you just want to strech an element on the entire screen you can use a different approach.
jsFiddle Demo
.fullscreen { position: absolute; top: 0; left: 0; bottom: 0; right: 0; }
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