First, let's take a look at the relative length units of CSS3 (refer to the detailed tutorial): Relative length units specify the property of one length relative to another length. Relative lengths are more applicable to different devices.
It can be seen that through vh / vw we can get the current screen window width, so in CSS, by calculating this height, the height of the div can be automatically expanded to the screen height. To calculate this height, you can use the calc() function of CSS3 (refer to the detailed tutorial): The calc() function is used to dynamically calculate the length value.
So, just set the height of the div to calc(100vh) , 100vh = 100% of the window height, example: div { width: 100%; height: calc(100vh); } It should be noted that this method is suitable for the web page height being equal to the current screen window height, and JS may still be required according to actual needs. This is the end of this article about how to use calc() in CSS to get the current visible screen height. For more information about how to use calc() in CSS to get the current screen height, 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! |
<<: Discuss the value of Web standards from four aspects with a mind map
>>: Some simple implementation codes of the form element take registration as an example
Table of contents Overview Code Implementation Pa...
Table of contents 1. Basic usage and logic 2. Fea...
Phenomenon: Run an image, for example, ubuntu14.0...
Professional web design is complex and time-consu...
Table of contents 1. List traversal 2. The role o...
The blogger said : I have been writing a series o...
1 Introduction Kong is not a simple product. The ...
Table of contents 1 Introduction 2 Basic usage 2....
This article example shares the specific code for...
Table of contents forEach() Method How to jump ou...
Here is a single-line layout using ul>li for l...
Vue $set array collection object assignment In th...
Preface By default, Nginx logs are written to a f...
The installation of mysql5.7.18zip version on Win...
I recently wrote a script for uploading multiple ...