Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non uniform grid float

Hey im trying to make a floating grid that has different shapes.

Here is my goal and whats happening: http://imgur.com/a/wXQfA

As you can see there is a gap under the horizontal piece. Im trying to fix it without having to use any positioning so that I can add boxes on later or move them around.

Code: Html

        <li class="mediumBox">
            <a href="#"><img src="..." height="205" width="430"></a>
        </li>

        <li class="largeBox">
            <a href="#"><img src="..." height="430" width="430"></a>
        </li>

        <li class="verticleMediumBox">
            <a href="#"><img src="..." height="430" width="205"></a>
        </li>

        <li class="smallBox">
            <a href="#"><img src="..." height="205" width="205"></a>
        </li>

        <li class="smallBox">
            <a href="#"><img src="..." height="205" width="205"></a>
        </li>

        <li class="smallBox">
            <a href="#"><img src="..." height="205" width="205"></a>
        </li>

        <li class="smallBox">
            <a href="#"><img src="..." height="205" width="205"></a>
        </li>
    </ul>
</div>
</body>

Css:

body{
background-color: #fffdf9;
height: 100%;
width: 100%;
}

#content{
background-color: red;
height: auto;
width: 900px;
margin: 5em auto 0 auto;
}

#work ul{
list-style: none;

}

#work li{
float: left;
margin:  10px;
}

#work li >a{
display: block;
}

#work li .smallBox{
float: left;
display: block;
}

#work li .mediumBox{
float: left;
display: block;
}

#work li .verticleMediumBox{
float: left;
display: block;
}

#work li .largeBox{
float: left;
display: block;
}

Here is my code:http://jsfiddle.net/jw7pV/ For some reason the jsFiddle version doesn't look like my chrome version.

like image 771
rikuto148 Avatar asked Jun 24 '13 17:06

rikuto148


1 Answers

Edit: sorry didn't read the first time that you need dynamic boxes.

If the size of your columns scales (like some kind of responsive design) then you need something that will set these absolute positions dynamically. So you need javascript.

For that you can use jquery masonry or jquery isotope.

http://masonry.desandro.com/

http://isotope.metafizzy.co/

:)

like image 76
Kev Avatar answered Oct 15 '22 10:10

Kev