Tag:Parent element
-
Time:2020-11-21
Usually, a CSS selector is selected from top to bottom, and the child element is selected through the parent element. Can the parent element be selected through the child element? <ul> <li> <a href=”#” class=”active”>1</a> </li> <li> <a href=”#”>2</a> </li> </ul> If I want to choose Li with a.active, how can I implement it? At […]
-
Time:2020-11-16
Absolute positioning method: (1) Set the parent element to relative positioning. If the height of the parent element is not written, it will change with the height of the child element on the left .parent { /*Key code*/ position: relative; /*Other styles*/ width: 800px; color: #fff; font-family: “Microsoft Yahei”; text-align: center; } (2) When an […]
-
Time:2020-11-15
Solution Add to parent element position:relative;Add position:absolute; right:20px; code HTML structure <div id=”div1″> <div id=”div2″></div> </div> css #div1{ width:500px;height:500px; background-color:darkgray; position:relative; } #div2{ width:30px;height:30px; background-color:red; position:absolute; right:20px; } effect principle Browser rendering HTML, there is a saying of document flow, block level element line feed rendering, line element in line rendering, here, two div are […]
-
Time:2020-11-14
In the writing style, we can often see this situation The code is as follows <div style=”width: 300px;border: 4px solid #000;margin: 20px;padding: 2px;”> Parent element <div style=”border: 1px solid blue;height: 100px;white-space: nowrap;”> <span>Prime prime element</span> </div> </div> If you’ve thought about this phenomenon carefully, why? Might you ask, shouldn’t child elements widen the width […]
-
Time:2020-11-12
Basic concepts Absolute: the element box set to absolute positioning is completely removed from the document flow and positioned relative to its containing block, which may be another element in the document or the initial containing block. The space that the element originally occupied in the normal document flow is closed as if the element […]
-
Time:2020-11-8
1、 Document flow and floating 1. What is document flow? In HTML, a document stream can also be called a standard stream or a normal stream. The display mode of elements is from top to bottom, from left to right. Block level elements occupy one line by default. In line or in line block level […]
-
Time:2020-4-4
As you know, the position absolute of CSS is set according to the document by default. For example, after position: absolute, set left: 0; when top: 0, the element will be displayed in the upper left corner of the page. Sometimes we need to set the relative absolute position in the container of the parent […]