Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why did the 'div2' no in the second row of the left-most?
My code is:
HTML
<div>
<div style="width: 100px; height: 100px; float: left">div1</div>
 <label>div1label</label>
</div>
   <div>
 <div style="width: 100px; height: 100px; float: left">div2</div>
     <label>div2label</label>
   </div>

Now the effect is:
div1 div1label
(blank..)div2 div2label
But I want the effect is:
div1 div1label
div2 div2label
Posted
Comments
vinodkumarnie 29-Mar-13 3:39am    
What exactly you want..? How you want show content...? Horizontally or vertically..?

Hello,

Please have a loot at following sample
HTML
<!DOCTYPE html>
<html>
<body>
    <div>
        <div style="width: 100px; height: 100px; float: left">div1</div>
        <label style="float:left;">div1label</label>
    </div>
    <div>
        <div style="width: 100px; height: 100px; float: left;clear:left;">div2</div>
        <label style="float:left;">div2label</label>
    </div>
</body>
</html>

The one below is without float.
HTML
<!DOCTYPE html>
<html>
<body>
    <div>
        <div style="width: 100px; height: 100px; display:inline-block;">div1</div>
        <label>div1label</label>
    </div>
    <div>
        <div style="width: 100px; height: 100px;display:inline-block;">div2</div>
        <label>div2label</label>
    </div>
</body>
</html>

Regards,
 
Share this answer
 
v2
also try this
XML
<div>
   <div style="overflow-y:scroll;display: inline-block; writing-mode:lr-tb; word-wrap:break-word;white-space:normal;">div1</div>
    <label>div1label</label>
   </div>
      <div>
    <div style="overflow-y:scroll;display: inline-block; writing-mode:lr-tb; word-wrap:break-word;white-space:normal;">div2</div>
        <label>div2label</label>
      </div>
 
Share this answer
 
If not necessary you can avoid nesting and make its position property set to absolute and
give it co-ordinates through top and left:

XML
<div style="position:absolute;top:500px; left:100px">Hello</div>
<div style="position:absolute;top:500px; left:200px">World</div>



This will get the two division elements inline.
 
Share this answer
 
Try below..
HTML
<div>
        <div style="width: 100px; height: 100px; float:left;">
            div1</div>
        <label style=" float:left;">
            div1label</label>
    </div>
    <div style="clear:both;"></div>
    <div>
        <div style="width: 100px; height: 100px; float:left;">
            div2</div>
        <label style=" float:left;">
            div2label</label>
    </div>


clear: both; clears all the elements floated left or right.

To know more about clear property see below link...
http://www.w3schools.com/cssref/pr_class_clear.asp[^]
 
Share this answer
 
XML
<div style="width:50%; height: 100px; float: left;Clear:both;">div1</div>
   <label>div1label</label>
  </div>


XML
<div style="width:50%;height: 100px; float:right;clear:both;">div2</div>
       <label style="float:left;">div2label</label>
   </div>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900