CSS layout stretch

1. Telescopic layout applications:

Telescopic layout applications 
spindle: spindle Flex Flex container to configure the program, default horizontal 
lateral axis: axis perpendicular to the spindle axis side is called, the default or vertical 
direction: from left to right spindle default, default side shaft from top to bottom 

of the spindle shaft and the side not fixed by the flex-direction may be interchanged 

min-width setting this value is not set at the arrival px scaled 
max-width with the opposite upper 
flex can be placed inside each box free adjustment 

needs to be added to the box display: flex;
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        section {
            width: 80%;
            height: 200px;
            border: 1px solid pink;
            margin: 100px auto;
            /*给父级盒子添加flex*/  
            the display : Flex ;   / * telescopic arrangement pattern * / 
        } 
        sectionTop div { 
            
            height : 100% ; 
            Flex : . 1 ;   / * for each sub-account cassette parts * / 

        } 
        sectionTop div: Child-Nth (. 1) { 
            background-Color : Pink ; 
        } 
        sectionTop div: Child-Nth (2) { 
            background-Color : Purple ; 
            margin : 0 5px ; 
        }
        section div:nth-child(3) {
            background-color: pink;
        }
    </style>
</head>
<body>
    <section>
        <div></div>
        <div></div>
        <div></div>
    </section>
</body>
</html>
View Code

 

2. Telescopic cassette disposed fixed width

sectionTop div: Nth-Child (. 1) { 
            background-Color: Pink; 
            width: 300px by; 
        } 
        sectionTop div: Nth-Child (2) { 
            background-Color: Purple; 
            margin: 0 5px; 
            Flex:. 1; 
        } 
        sectionTop div: Child-Nth (3) { 
            background-Color: Pink; 
            Flex: 2; 
        } 
stretching when stretching 1 2 and 3 may not change

 

3. The layout of the telescopic arrangement

flex-direction: colomn; Column Layout
flex-direction: colomn; line layout

sectionTop { width: 80%; height: 200px; border: 1px Solid Pink; margin: 100px Auto; / * to the parent box Add Flex * / the display: Flex; / * telescopic arrangement pattern * / min-width: 500px; Flex -direction: column; }

Coroutine case column layout:

案例之协程
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }
        body {
            min-width: 320px;
            max-width: 540px;
            margin: 0 auto;
        }
        header {
            width: 100%;
            height: 100px;
        }
        header img {
            width: 100%;
            height: 100%;
        }
        nav {
            padding: 5px;
        }
        .row {
            height: 90px;
            width: 100%;
            background-color: #ff697a;
            border-radius: 8px;
            display: flex;
            margin-bottom: 5px;
        }
        nav .row:nth-child(2) {
            background-color: #3d98ff;
        }
        nav .row:nth-child(3) {
            background-color: #44c522;
        }
        nav .row:nth-child(4) {
            background-color: #fc9720;
        }
        .row3 {
            flex: 1;
            border-left: 1px solid #fff;
        }
        row div:first-child {

        }
        .hotel {
            display: flex;
            flex-direction: column;
        }
        .hotel a {
            flex: 1;
            font-size: 16px;
            color: #fff;
            text-align: center;
            line-height: 45px;
            text-decoration: none;
            text-shadow: 0 1px 2px rgba(0,0,0, .3)

        }
        .hotel a:first-child {
            border-bottom: 1px solid #fff;
        }

    </style>
</head>
<body>
    <header>
        <img src="image/ctrip.jpg" alt="">
    </header>
    <nav>
        <div class="row">
            <div class="row3"></div>
            <div class="row3 hotel">
                <a href="#">海外酒店</a>
                <a href="#">特价酒店</a>
            </div>
            <div class="row3 hotel">
                <a href="#">团购</a>
                <a href="#">客栈</a>
            </div>
        </div>

        <div class="row">
            <div class="row3"></div>
            <div class="row3 hotel">
                <a href="#">海外酒店</a>
                <Cheap hotels>= "#"hrefA</a>
            </div>
            <div class="row3 hotel">
                <a href="#">团购</a>
                <a href="#">客栈</a>
            </div>
        </div>

        <div class="row">
            <div class="row3"></div>
            <div class="row3 hotel">
                <a href = "#" > Hongkong Hotels </ A > 
                < A href = "#" > hotels </ A > 
            </ div > 
            < div class = "row3 Hotel" > 
                < A href = "#" > buy </ A > 
                < A the href = "#" > Inn </ A > 
            </ div > 
        </ div > 

        <div class="row">
            <div class = "row3 Hotel" > 
                < A href = "#" > Hongkong Hotels </ A > 
                < A href = "#" > hotels </ A > 
            </ div > 
            < div class = "row3 Hotel" > 
                < A href = "#" > Hongkong Hotels </ A > 
                < A href = "#" > hotels </ A > 
            </ div >
            <div class="row3 hotel">
                <a href="#">团购</a>
                <a href="#">客栈</a>
            </div>
        </div>
    </nav>
</body>
</html>
View Code

 

4. Adjust the alignment of the spindle

justify-content adjustment spindle alignment 

values described 
flex-start from the beginning of the sub-elements so that sorting of the parent element 
of the container at the end of flex-end 
center located at the center of the container 
approximately close to the middle of the parent space-between the box blank from the distribution 
space-around corresponds to each a box to add a margin of each box

 

5. Adjust the vertical alignment

align-items to adjust the vertical alignment 
value describes 
stretch so highly stretched parent container adapted to a child element (child element is not provided to the height) 
Center vertically centered 
flex-start start position vertically aligned with 
flex-end position vertically aligned with the end

 

6. Control whether newline

nowrap: No Wrap force corresponding to the default display line 
wrap wrap 
wrap-reverse

 

7. Multi-line vertical alignment adjustment

align-content inside the stack for the case of multi-axial flex, align-items for one line is 
to be set to display his father: flex; 
flex-direction: Row; manner and arranged transversely wrap-flex: wrap; 

to strech 
Center 
flex-Start 
End-Flex 
Space-BETWEEN 
Space-around effect with attribute align-items of the same 

order before and after the sub-order control box 
smaller values can be written more forward negative default 0

 

Guess you like

Origin www.cnblogs.com/guniang/p/11937633.html