CSS3 Flex: Pull child to the right

前端 未结 1 811
萌比男神i
萌比男神i 2020-12-13 03:26

here\'s what I have Fiddle

相关标签:
1条回答
  • 2020-12-13 03:59

    Simple fix, use an auto-adjusting margin:

    ul li:last-child {
        margin-left: auto;
    }
    

    You may also want to not use width: 100% so that the element stays inside the visible area:

    ul {
        display: flex;
        justify-content: flex-start;
        flex-direction: row;
        align-items: center;
        /* width: 100%; */
        height: 100px;
        background: #333;
        padding: 15px;
    }
    

    http://jsfiddle.net/dwLHE/

    See also https://www.w3.org/TR/css-flexbox-1/#auto-margins

    0 讨论(0)
提交回复
热议问题