Home css Wrap the block with other blocks

Wrap the block with other blocks

Author

Date

Category

Suppose there is some code like this http://jsfiddle.net/h0czgwgu/

. left {
 width: 50px;
 height: 50px;
 border: 1px solid black;
 float: left;
 background-color: white;
}
.content {
 width: 100%;
 height: 10px;
 margin: 3px;
 border: 1px solid black;
 background-color: green;
} 
& lt; div class = "left" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt; 

Answer 1, authority 100%

Remove width, add overflow: hidden and drag margin to float edge:

. left {
 width: 50px;
 height: 50px;
 border: 1px solid black;
 float: left;
 background-color: white;
 margin-right: 3px;
}
.content {
 height: 10px;
 margin: 3px 0;
 border: 1px solid black;
 background-color: green;
 overflow: hidden;
} 
& lt; div class = "left" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt;
& lt; div class = "content" & gt; & lt; / div & gt; 

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions