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
Table of contents Method 1 1. Configuration and i...
This article uses a jQuery plug-in to create an a...
ssh-secure shell, provides secure remote login. W...
Syntax format: row_number() over(partition by gro...
1. HTML font color setting In HTML, we use the fo...
Shopify Plus is the enterprise version of the e-c...
We can view the installation path of mysql throug...
Tips: Array change method will cause v-for to upd...
Nginx supports three ways to configure virtual ho...
Because I wrote a Python program and intensively ...
1. Install shadowsocks sudo apt-get install pytho...
A while ago, I wrote a blog post titled "Can...
Find the problem Recently, I found a problem at w...
Vim is a text editor that we use very often in Li...
1. Install zabbix-agent on web01 Deploy zabbix wa...