次のように表示される一連の画像を呼び出すphpスクリプトがあります。
これは、それらを呼び出す php コードです。
<?php
$query = "SELECT
parent_business_id,
image_url,
alt_tag,
description,
thumb_url,
business
FROM
images
ORDER BY
RAND()
LIMIT
6
";
$result = mysql_query($query, $dbc)
or die (mysql_error($dbc));
while($row = mysql_fetch_array($result)) {
$parent = $row["parent_business_id"];
$image = $row["image_url"];
$alt = $row["alt_tag"];
$description = $row["description"];
$thumb = $row["thumb_url"];
$business = $row["business"];
$mainthumb = "./images/270x270/$image.jpg";
echo
"<div class='gallery_image_container'>
<a href='business-profile.php?business_id=$parent' class='gallery_darken'><img src='$mainthumb' alt='$alt' title='$description' /></a>
</div>";
}
?>
現時点では、css3 の nth-child を使用して中央の画像にマージンを追加しています。
div.gallery_image_container:nth-child(3n+2){
margin-left:10px;
margin-right:10px;
}
私が抱えている問題は、css3 をサポートするブラウザーではこれがうまく機能することですが、つまり 7 と 8 ではサポートされず、解決策が必要です。PHPでクラスを追加することでこれを行うことができるのではないかと考えています。もしそうなら、どの機能を使用しますか。PHPにセレクターのようなn番目の子はありますか?