Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't float inside div with position fixed

http://jsfiddle.net/1351qL91/

<div style="width:200px"> 
<span style="float:left">left</span>
<span style="float:right">right</span>
<br/>
<div style="position:relative">
    <span style="float:left">left</span>
    <span style="float:right">right</span>
<div>
<br/>
<div style="position:fixed"> 
    <span style="float:left">left</span>
    <span style="float:right">right</span>
</div>

spans with float right won't float right inside a div with position fixed.

I came to the conclusion that float won't work if the container's width is unknown, and in this case the width is indeed unknown.

So another question which may solve this problem is how to set a fixed position child to 100% width of it's parent?

P.S I'm using bootstrap 3, which means the container div (which I set to 200px) is actually of class col-md-3 -> I don't know the width of the container, that's why I need it to be dynamic

like image 688
Alonzzo2 Avatar asked Sep 16 '26 03:09

Alonzzo2


1 Answers

Floating wont work inside fixed or absolute divs unless you specify width.

You cannot use position:fixed to position inside the bootstrap grid. Fixed positioned divs are relative to the browser. You need to use absolute positioning.

like image 141
Felix A J Avatar answered Sep 20 '26 20:09

Felix A J