Preface Sometimes you need to keep the height of a box container at 100% at all times, no matter how you zoom the browser. Just like the sidebar on some websites, but directly setting the height of the box container to 100% does not work. demo If you want an element's percentage height: 100%; to work, you need to set a valid value for the height of all of its parent elements. Take the demo below for example. The parent elements of div are body and html. So just set both the parent element and the element itself to 100% height. <!DOCTYPE html> <html> <head> <title>Document</title> </head> <body> I want the <div> to have 100% height so I can scale it as I like. </div> </body> </html> CSS: html,body,div{ height:100%; } /* Simply add some styles to the div */ div{ background:red; width:200px; } Effect: This is the end of this article about how to set the box container (div) height to always be 100% with CSS. For more information about how to set the div height to always be 100%, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: MySQL foreign key constraint (FOREIGN KEY) case explanation
>>: jQuery implements all shopping cart functions
How to solve the problem of being unable to acces...
1. Why is eject not recommended? 1. What changes ...
This article records the detailed installation tu...
<br />Original address: http://andymao.com/a...
Table of contents Preface Laying the foundation p...
1. Introduction to Layer 4 Load Balancing What is...
The query data in the xml price inquiry contains ...
Preface This article records how I use docker-com...
Problem Description When VMware Workstation creat...
Table of contents 1. Parent components and child ...
This article shares the specific code of using ca...
1. Install JDK 1. Uninstall the old version or th...
This article shares the specific code of jQuery t...
I encountered mysql ERROR 1045 and spent a long t...
MySQL Introduction to MySQL MySQL was originally ...