9
<div id="Content">
    <div id="loginContent"></div>
    <div id="signupContent"></div>
</div>

I have a root div here. I want to display the child divs horizontally. How to do this?

Hristo Enev
  • 2,421
  • 18
  • 29
Xiaojian
  • 149
  • 1
  • 1
  • 6

2 Answers2

10

You mean this?

Flexbox:

#Content {
  display: flex;
}

#loginContent {
  flex: 1;
}

#signupContent {
  flex: 1;
}

Floats:

#loginContent,
#signupContent {
  float: left;
  width: 50%;
}

Inline-block:

#Content {
  text-align: center;
}

#loginContent,
  #signupContent {
  display: inline-block;
}
DeFeNdog
  • 1,156
  • 1
  • 12
  • 25
  • The issue is, if I change the display(inline-block) or float(left), they both go to left with the second div lying under the first one.. – Xiaojian Sep 18 '14 at 18:39
0

Use inline-block Fiddle:

#loginContent, #signupContent {
display: inline-block;

}

or you can use float Fiddle:

#signupContent {
float: right;

}

Sergey6116
  • 124
  • 5