In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the float attribute in CSS. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
In CSS, we float the element through the float attribute.
Line frames and cleanup
The floating box your row box is compressed to make room for the floating box, which surrounds the floating box.
Therefore, establishing a floater allows the text to surround the image:
To stop the row box from lingering around the floating box, you need to apply the clear property to the box. The value of the clear property can be left, right, both, or none, which indicates which edges of the box should not be next to the floating box.
To accomplish this, increase the scarce space on the top and outer margins of the cleaned element so that the top edge of the element falls vertically below the floater:
This is a useful tool that allows nearby elements to make room for floating elements.
Let's look at floats and liquidations more specifically. If you want an image to float to the left of a text block, let's hope that the picture and text are clustered in another element with background colors and borders. You can either write the following code:
.news {bac kg round-color: gray; border: solid 1px black;} .news img {float: left;} .news p {float: right;}
Some text
In this kind of environment, a problem arises. Because the floating element is detached from the document stream, there is no room for the div that surrounds images and text.
How to let the saved element visually unenclose the floating element? You need to apply clear somewhere in this element:
Unfortunately, a new problem arises, and since there is no existing element to apply liquidation, we can only add an empty element and clean it up.
.news {bac kilogram round-color: gray; border: solid 1px black;}. News img {float: left;} .news p {float: right;} .clear {clear: both;}
Some text
This can achieve the desired effect, but we need to add excess code. There are always elements that can use clear, but there are times when you have to add symbols without meaning for the sake of structure.
It's just that we have another way to float the container div:
.news {bac kilogram round-color: gray; border: solid 1px black; float: left;}. News img {float: left;} .news p {float: right;}
Some text
How it will achieve the results we crave. Unfortunately, the next element is affected by this floating element. In order to plan this title problem, some people choose to float all the equipment in the structure, and then use the appropriate intentional elements (often the footer of the site) to settle these floating developments. This helps to reduce or eliminate unnecessary signs.
After all, all the pages on the W3School site use this technique, and if you open the CSS file we use, you will see that we have cleared the div in the footer, while the three div under the footer float to the left.
Thank you for reading! This is the end of this article on "how to use float attributes in CSS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.