...

View Full Version : I'd like to arrange some divs like this using CSS...



Raerae
04-27-2011, 06:15 AM
__________________
|_____|_____|_____|
|_____|_____|_____|




Each box above being one div containing a centered image, how can I do that? I can't seem to figure it out. I'm fairly new to CSS. Help please? :)

msevrens
04-27-2011, 06:50 AM
you gotta float the divs to the left:
http://css-tricks.com/all-about-floats/

Solution for centering:
http://www.brunildo.org/test/img_center.html

Raerae
04-27-2011, 08:42 AM
Thanks so much. Whoever wrote that thing on csstricks is very clear, never understood the concept of floats and collapses like that.

Now what if I wanted to center the cluster of divs on the page?

gkarthik21
04-27-2011, 09:11 AM
Thanks so much. Whoever wrote that thing on csstricks is very clear, never understood the concept of floats and collapses like that.

Now what if I wanted to center the cluster of divs on the page?

Try to put the div inside a table and align the table to center...or put all the divs inside a div and align tat div in center...

effpeetee
04-27-2011, 11:01 AM
Try to put the div inside a table and align the table to center...

Check this out first. (http://www.hotdesign.com/seybold/)

Frank

coothead
04-27-2011, 11:37 AM
Hi there Raerae,

you may find the following example mildly interesting or not. ;)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

<base href="http://www.coothead.co.uk/images/">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<title>thumbnails 6x?</title>

<style type="text/css">
body {
background-color:#fed;
}
#gallery {
list-style-type:none;
width:1020px;
padding:40px 40px 32px 40px;
border:3px double #c60;
margin:20px auto 0;
background-color:#fc9;
overflow:hidden;
box-shadow: #323 30px 30px 40px;
-moz-box-shadow: #323 30px 30px 40px;
-webkit-box-shadow:#323 30px 30px 40px;
border-radius:25px;
-moz-border-radius:25px;
-webkit-border-radius:25px
}
#gallery li {
width:160px;
padding:15px 0;
border:1px solid #c60;
margin:0 4px 8px 4px;
float:left;
font-family:verdana,arial,helvetica,sans-serif;
font-size:0.8em;
text-align:center;
background-color:#fed;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px
}
#gallery img {
padding:4px;
margin-top:8px;
border:3px double #f96;
background-color:#fff;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px
}
#gallery a {
color:#630;
text-decoration:none;
}
</style>

<!--[if lt IE 8 ]>
<style type="text/css">
#gallery {
padding:40px 40px 32px 32px;
}
</style>
<![endif]-->

</head>
<body>

<ul id="gallery">
<li><a href="#"><img src="anim.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim1.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim2.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim3.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim4.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim5.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim1.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim2.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim3.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim4.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim5.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim2.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim3.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim4.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim5.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim.gif" alt=""><br>description</a></li>
<li><a href="#"><img src="anim1.gif" alt=""><br>description</a></li>
</ul>

</body>
</html>

coothead

Raerae
04-28-2011, 10:33 PM
Check this out first. (http://www.hotdesign.com/seybold/)

Frank

Yeah I'm actually trying not to use tables at all.

bullant
04-28-2011, 11:01 PM
Something like this?

This demo displays 2 rows of 3 containers each with red borders centered on the page. You can then put whatever you like in each <li>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title></title>
<style type="text/css">
#myList {
list-style-type: none;
width: 70%;
margin: 0px auto 0px auto;
}
#myList li {
float: left;
width: 32%;
height: 20px;
border: 1px solid red;
}
</style>
<script type="text/javascript"></script>
</head>
<body>
<ul id="myList">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>

Raerae
05-07-2011, 09:01 PM
Thanks guys for answering, really appreciate it. Ended up not needing after all. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum