What should be done when the float attribute causes a line break?

yulia
Release: 2018-09-21 15:46:52
Original
2445 people have browsed it

Page layout is inseparable from the use of float. When the float attribute causes line breaks, what should be done? Friends who want to know, please continue to read below, I hope it can help you.

In h5 development, float attributes are often used to solve some layout problems. However, in some complex layouts, you may also encounter phenomena such as using the float attribute, which causes the elements in a row to be unable to be aligned or the float elements to wrap. When encountering this kind of problem, we can modify the position of the element to solve the problem of line wrapping or misalignment of elements.

<div class="container">
    <a href="address-manager.html">
        <i class="icon-home icon-large"></i>
        <p>修改收货地址</p>
        <i class="icon-angle-right icon-2x"></i>
    </a>
</div>
Copy after login

For example, when I was writing a menu-like layout, this phenomenon occurred in the "Modify Address" column. When I put the element that I want to float to the right (the right arrow) in the code Adjusting to the position of the first element solves the problem of float line wrapping.

Since various browsers have some differences in styles, there is another situation where the line wrap problem will occur when the width of the element floating to the right is not enough. In this case, it can be solved by simply modifying the width.

Next, let’s summarize the relevant characteristics of the float attribute learned during the information search process:

float is a floating positioning attribute in css

Features:

1. The float box can float left and right until its outer edge encounters the containing box or another floating box;

2. The floating box breaks away from the regular flow of the document, and the regular flow of the document will ignore the float. The existence of the box;

3. The floating box will not affect the layout of the block-level box, but will affect the arrangement of the inline box;

4. When the height of the floating box exceeds the containing box (that is, the parent layout), the containing box will not automatically stretch its height. If the containing box does not include other ordinary flows, the height of the containing box will be 0, which is the so-called height collapse phenomenon.

The above situation is actually a manifestation of the floating box affecting the inline box.

The above is the detailed content of What should be done when the float attribute causes a line break?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!