In-depth analysis of the unexpected "floating trap" in Chapter 4 of CSS-reading notes

tags: HTML\CSS  css  html  html5  css3

4.3 Unexpected "floating trap"

  • The third box appeared on the right, causing a very large blank space under the first box. This is because the browser will place the floating element as high as possible.
  • If the height of each floating box is different, the final layout may be ever-changing. In the same way, changing the width of the browser will have the same result, because it will cause line breaks and thus change the height of the element. What we really want is two floating boxes per row.

solution:

  • Clear the float above the first element of each row. Since it is known that there are two boxes in each row, you only need to clear the float in the row above the odd-numbered element of each row.

Add margins to media elements

  • The previous owl selector will also add a top margin to each element except the first element, because this will cause the elements in the first row to be unaligned, so you need to reset the top margin of the media element.

Intelligent Recommendation

In-depth analysis of CSS Chapter 3 element width issues-reading notes

3.1 The problem of element width How to build the following simple web page? Write HTML first Write basic style CSS code Explain that because IE has a bug, it will default to<main>Elements are r...

In-depth analysis of the fourth chapter of CSS grid system-reading notes

4.5 Grid System The reusability of code can be improved with the help of grid system The grid system provides a series of class names that can be added to the markup to structure a part of the web pag...

In-depth analysis of the element spacing in the container in the third chapter of CSS-reading notes

Element spacing in the container Add two social buttons to the sidebar Set the size, font, and color of the sidebar buttons At this time, they are stacked directly on top of each other without margins...

In-depth analysis of CSS Chapter 5 Flexbox principles-reading notes

5.1 Principles of Flexbox Add to the elementdisplay:flex, The element becomes aFlexible container(Flex container), its direct child element becomesElastic sub-element(flex item) The height of the elas...

In-depth analysis of CSS Chapter 2 custom attributes-reading notes

Custom attributes Declare a variable, assign a value to it, and then refer to this value elsewhere in the style sheet, which can reduce duplication in the style sheet example: Define a custom attribut...

More Recommendation

In-depth analysis of the first chapter of CSS inheritance-reading notes

If an attribute of an element does not have a cascading value, it may inherit the value of an ancestor element Properties that can be inherited Text-related attributes color, font, font-family, font-s...

In-depth analysis CSS second chapter stop pixel thinking - reading notes

2.3 Stop pixel thinking Inverse mode: global reset font-size is 10px (from the default font size 16px to 10px, easy to calculate the value of the REM) Disadvantages: Need to write a lot of repetition ...

In-depth analysis of CSS Chapter 1 laminated - reading notes

Box model and border-box When specifying the width or height of an element, the size of the element content is set - any inner margin (padding), border, the outer distance (margin) is superimposed bas...

C-depth analysis of reading the first chapter notes

Chapter One 1. The difference between declarations and definitions Statement multiple times, only once defined, allocated memory is defined at the same time. 2.static Modifying variables: Static globa...

In-depth analysis of the size of the elastic sub-elements in CSS Chapter 5-reading notes

5.2 The size of the elastic child element The flex attribute controls the size of the elastic child element in the main axis direction Set the main container to Flexbox Use the flex attribute to set t...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top