How to make height adaptive in css

藏色散人
Release: 2021-04-08 10:35:03
Original
9923 people have browsed it

How to make height adaptive in css: 1. Set the height of the parent layer to the "height:auto;" style attribute; 2. Add the "overflow:hidden;" style attribute to the added parent layer, and then create a new one Place the div at the back and add the style attribute "clear:both".

How to make height adaptive in css

The operating environment of this article: windows7 system, HTML5&&CSS3&&HBuilderX v2.1.3.20190723 version, Dell G3 computer.

Open the web development tool and create a new HTML file (here for the convenience of demonstration)

How to make height adaptive in css

Normal layout: Just set the outer height to: height: auto; attribute can be adaptive:

How to make height adaptive in css

Method 2 (floating layout):

If the child element sets the float attribute, the outer DIV It cannot be opened automatically, as shown in the figure:

How to make height adaptive in css

Solution 1: Add the following to the parent layer: overflow: hidden; attribute

How to make height adaptive in css

Solution 2: Create a new div and put it at the back, and add the style: clear: both;

How to make height adaptive in css

[Recommended learning: css video tutorial

The above is the detailed content of How to make height adaptive in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template