Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

align div to another div

I have two divs, like the image attached. Mi problem is that div2 didn't go under div1 (when div1 finish), as shown in image1, but remains in column (like the second image attached).

first image second image

div1 css is:

width: 391px;
height: 380px;
float: left;
margin-right: 10px;

while div2 css ishas no css (i don't know what to insert).

How can i do?

Thanks, Mattia

like image 664
pindol Avatar asked Jun 19 '26 19:06

pindol


2 Answers

Assuming your markup is

<div id="div1">...</div>
<div id="div2">...</div>

You have to do absolutely nothing, since if div2 has no style applied then the whole layout will be like that on figure 1

see fiddle: http://jsfiddle.net/qAqv3/

like image 109
Fabrizio Calderan Avatar answered Jun 22 '26 10:06

Fabrizio Calderan


A div can have only one width and only one height, so it can only be a rectangle. You could insert your div1 into div2, and set the content of div2 (including div1) with float:left .

Here is a demo : http://jsfiddle.net/DX2vJ/1/

like image 24
gabitzish Avatar answered Jun 22 '26 09:06

gabitzish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!