Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my html

HTML
<div class="parent">
    <div class="child">1</div>
    <div class="child">2</div>
    <div class="child">3</div>
    <div class="child-wide">4</div>
    <div class="child">5</div>
    <div class="child">6</div>
    <div class="child">7</div>
</div>


my css

CSS
.parent { 
width:408px; 
display:inline-block; 
background-color:orange;
color:white;
}
.parent div {
float:left;
height:100px;
background-color:green;
border:1px solid white;
font-size:36px;
text-align:center;
}
.child { width:100px;}
.child-wide { width:202px;}

how to float child fill in space div parent? sorry, my english very bad.
Posted
Updated 22-May-15 6:05am
v3
Comments
Sergey Alexandrovich Kryukov 22-May-15 12:59pm    
If you want to float some elements, why using div? If you remove all inner div markup, you will get floating text. For styling some elements inside it, use span.
—SA
Richard Deeming 22-May-15 13:25pm    
Are you looking for Flexbox[^]?

Browser support[^] is pretty good, apart from old version of Internet Explorer.

1 solution

If you're wanting the elements side-by-side you could also look at using
CSS
display: inline-block 
on the child class as this will align them in a line rather than beneath one another.
 
Share this answer
 

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