0

How am I suppose to put two <div> next to each other?

13th Jul 2016, 10:16 AM
meysam
meysam - avatar
8 Answers
+ 5
You need to set the div's dimensions and use 'float' property :)
13th Jul 2016, 11:53 AM
ThreeG
ThreeG - avatar
+ 2
Floating elements is an alternative way of positioning. No need to use relative nor absolute positioning with it. But, if you use fixed widths for both floated elements and their container, you have to make sure their total width + margins do not ecxeed the container's width. You can also use 'flex' positioning but only modern browsers support it.
14th Jul 2016, 5:37 AM
ZinC
ZinC - avatar
+ 1
Hmm weird, do you use position:relative? Maybe that's reason of overlapping
13th Jul 2016, 5:06 PM
ThreeG
ThreeG - avatar
+ 1
It has to be relative! found it in stackoverflow yesterday. this stuffs are really confusing 😄 tnx Three G
14th Jul 2016, 4:56 AM
meysam
meysam - avatar
+ 1
use float: left ; in css for first div
15th Jul 2016, 7:24 AM
manish rawat
manish rawat - avatar
+ 1
I think in CSS: display:inline-block
15th Jul 2016, 8:46 AM
Shalom Ori Danino
Shalom Ori Danino - avatar
0
tnx, but float makes them overlap 😭
13th Jul 2016, 2:32 PM
meysam
meysam - avatar
0
yeah ZinC. I needed another div container to achieve my expected result. the link blow has a solution http://stackoverflow.com/questions/446060/css-two-divs-next-to-each-other thanks guys
15th Jul 2016, 4:11 PM
meysam
meysam - avatar