css3
  • flexbox
  • 2016-09-16 106 views 0 likes 
    0
    <div class="flex-container"> 
        <div class="flex-item" style='width:15%'>flex item 1</div> 
        <div class="flex-item" style='width:15%'>flex item 2</div> 
        <div class="flex-item" style='width:15%'>flex item 3</div> 
    </div> 
    

    在上面的例子中,我想項目1,和,第2項和3使用CSS3 Flexbox的頁的右側。CSS3 Flexbox的,左和上左側向右浮動項

    在此先感謝

    +0

    你目前有什麼CSS?它怎麼不起作用? – iblamefish

    +0

    .flex-container {display:-webkit-flex; display:flex; } –

    +0

    @prasadparab https://css-tricks.com/snippets/css/a-guide-to-flexbox/這可以幫助你。 –

    回答

    5

    https://jsfiddle.net/y9o1utqk/

    <div class="flex-container"> 
        <div class="flex-item">flex item 1</div> 
        <span></span> 
        <div class="flex-item">flex item 2</div> 
        <div class="flex-item">flex item 3</div> 
    </div> 
    
    .flex-container{ 
        display:flex; 
        flex-direction:row; 
        border:2px blue solid; 
    } 
    
    .flex-container > span{ 
        flex-grow:1; 
    } 
    
    .flex-container > .flex-item{ 
        border:2px red solid; 
        flex-grow:0; 
        width:15%; 
    } 
    

    或者:

    https://jsfiddle.net/y9o1utqk/1/

    <div class="flex-container"> 
        <div class="left">flex item 1</div> 
        <div class="right"> 
        <div class="flex-item">flex item 2</div> 
        <div class="flex-item">flex item 3</div> 
        </div> 
    </div> 
    
    .flex-item{ 
        border:4px red solid; 
        flex-grow:0; 
        width:15%; 
    } 
    
    .flex-container{ 
        display:flex; 
        flex-direction:row; 
        border:4px blue solid; 
        justify-content:space-between; 
    } 
    
    .flex-container > .left{ 
        width:15%; 
        border:4px red solid; 
    } 
    
    .flex-container > .right{ 
        display:flex; 
        flex-direction:row; 
        border:4px lime solid; 
        width:30%; 
    } 
    
    .flex-container > .right > div{ 
        border:4px red solid; 
        width:50%; 
    } 
    
    +0

    是的,這是我想要的。但是,你能告訴我爲什麼你增加了額外的跨度嗎?沒有跨度可以嗎? –

    +0

    它將左邊與右邊分開。我發佈另一個解決方案。一探究竟 – Wes

    相關問題