Welcome to WebmasterWorld Guest from 54.145.173.36

Forum Moderators: not2easy

Message Too Old, No Replies

Style 3 then miss 3 then style 3

   
9:55 am on Apr 10, 2013 (gmt 0)

5+ Year Member



I've used a layout which has a grid of 3 blocks by an infinite number of rows. Is there any way that I can style the first 3 blocks, miss the next 3, style the next 3 etc etc?

I've used :nth before but not sure it can do this?

Any help would be greatly appreciated.
11:42 am on Apr 10, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, (n+3) can do that, but I just woke up and can't think.
12:37 pm on Apr 10, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there greencode,

actually, this will need; (6n+1), (6n+2) and (6n+3). ;)

Here is an example....


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

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">

<title>every other row</title>

<style type="text/css">
body {
background-color:#f0f0f0;
font-family:verdana,arial,helvetica,sans-serif;
font-size:1em;
}
ul {
width:462px;
padding:2px;
margin:20px auto 0;
border:1px solid #999;
background-color:#fff;
box-shadow:10px 10px 10px rgba(0,0,0,0.5);
list-style-type:none;
overflow:hidden;
}
li {
float:left;
width:148px;
margin:2px;
border:1px solid #000;
background-color:#666;
color:#fff;
}
li:nth-child(6n+1),li:nth-child(6n+2),li:nth-child(6n+3){
border-radius:5px;
border-color:#999;
background-color:#fff;
box-shadow:inset 0 0 10px rgba(0,0,0,0.3);
line-height:2.0em;
font-family:georgia,'times new roman',serif;
font-size:1.5em;
font-weight:bold;
color:#000;
text-align:center;
}
</style>

</head>
<body>

<ul>
<li>row 1</li><li>row 1</li><li>row 1</li>
<li>row 2</li><li>row 2</li><li>row 2</li>
<li>row 3</li><li>row 3</li><li>row 3</li>
<li>row 4</li><li>row 4</li><li>row 4</li>
<li>row 5</li><li>row 5</li><li>row 5</li>
<li>row 6</li><li>row 6</li><li>row 6</li>
<li>row 7</li><li>row 7</li><li>row 7</li>
<li>row 8</li><li>row 8</li><li>row 8</li>
<li>row 9</li><li>row 9</li><li>row 9</li>
</ul>

</body>
</html>



birdbrain
1:20 pm on Apr 10, 2013 (gmt 0)

5+ Year Member



Fantastic, that works beautifully. Thanks for your help.
1:30 pm on Apr 10, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem, you're very welcome. ;)


birdbrain