user3638287 user3638287 - 3 months ago 15
CSS Question

Can't make a div float right (may be because of flexbox?)

Basically, got a container div in the middle of the page and 2 children divs. Need the right one to be at the very right of container. Float:right doesn't work. Can't use margin-left since i want it to work with any resolution. Right:0 doesn't work as well. Using flexbox. May be it has something to do with it.

html code

<div class="parent">
<div class="child1">adsfasdfdsa</div>
<div class="child2">192837192</div>
</div>


css code

.parent {
-o-display:flex;
-webkit-display:flex;
-ms-display:flex;
-moz-display:flex;
display:-webkit-box;
display:-webkit-flex;
display:flex;
width:80%;
margin:0 auto;
}
.child2 {float:right;}


here is a fiddle
http://jsfiddle.net/82yXE/

Answer

Use position:absolute; and right:11%

Here is what it looks like.