ordering in css with 100% width

2019-09-08 05:42发布

问题:

I want child div with 100% width.

Is it possible or not ?

html

<div class="main">
    <div class="order2">order2</div>
    <div class="order1">order1</div>
</div>

css

.main{
    display: flex;
}

.order1{
 order:1;
 width:100%;
}
.order2{
 order:2;
width:100%;
}

link > http://jsfiddle.net/gobmo8sL/

回答1:

you can adjust the directing of the 'flex' display

.main{
    display: flex;
    flex-direction: column;
}

http://jsfiddle.net/gobmo8sL/2/



回答2:

Add flex-direction: column;

.main{
display: flex;
flex-direction: column;
}


回答3:

Any reason for using display:flex for the parent div? If you remove that, you are getting a full width child. Also, if you are looking for a listing, go for

<ul> <li> </li></ul>

structure.



标签: css3