Reputation: 7792
So I have two divs like this
<div class="parent">
<div class="child1"/>
<div class="child2"/>
</div>
child1 is position: fixed, and I want child2 and child1 to be side by side.
I've tried using inline-block, but that doesn't work. What should I do?
Upvotes: 0
Views: 1715
Reputation: 7668
Here is JSBIN
.child1 {
position:fixed;
}
.child2{
float:right;
margin-right:350px;
}
Upvotes: 1
Reputation: 1636
Once you put something 'fixed' it's out of the flow so you can absolutely position child 2 but it will move relative to the container it's in
Upvotes: 0
Reputation: 1316
Enclose the elements that should be fixed in a container, set that container to position:fixed
, and position its children accordingly. Perhaps with float:left
and float:right
.
<div class="parent">
<div class="fixed-container">
<div class="child1"/>
<div class="child2"/>
</div>
</div>
Upvotes: 2