praks5432
praks5432

Reputation: 7792

Make two divs side by side where one has position fixed

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

Answers (3)

Naveen Kumar Alone
Naveen Kumar Alone

Reputation: 7668

Here is JSBIN

.child1 {
  position:fixed;
}
.child2{
  float:right;
  margin-right:350px;
}

May be it could be help you

Upvotes: 1

kelly johnson
kelly johnson

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

unblevable
unblevable

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

Related Questions