Left fixed width right adaptive layout method

Source: Internet
Author: User

In the development of business management system, you will encounter the left-width, right-wide adaptive problem, such as the following situation
Method One: Left floating, right width set 100%

            . left{
                float:left;
            }
            . right{
                width:100%;
            }

Method Two: Parent container settings display:flex;right partial settings flex:1

        . body{
                Display:flex;
            }
            . right{
                flex:1;
            }

Method Three: Set float + Use the Calc () function in CSS

            . left{
                float:left;
            }
            . right{
                Float:left;
                Width:calc (100vw-200px);
            }

Analysis
1. Floating. (Note: To not affect other elements, do not forget to clear the float on the parent)

Calc () = Calc (arithmetic) is used to dynamically calculate length values in CSS, it is important to note that the operators need to keep a space before and after the operator, for example: Width:calc (100%-10px);

Vw:viewport width. 1VW = viewport width of 1%, 100VW = viewport width,

And the same vh:viewport height. 1VW = viewport height of 1%, 100VH = viewport.

Browser support: Mainstream browser, ie10+

VW and VH change with the viewport, making them ideal for use in adaptive scenarios.

Reference original Address
[Https://www.cnblogs.com/wx1993/p/6727653.html]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.