我有以下页面,其中列出了我的吸引力"吸引力"表格显示:
<!DOCTYPE HTML>
<html>
<body>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="jquery.imagemapster.js"></script>
<link rel="stylesheet" type="text/css" href="css.css" />
<title>VisitBulgaria</title>
</head>
<div class="banner">
<a href="home.html">
<img src="images/banner.png" alt="kimtech" border="0" height="150" width="500" /></a>
<div class="namelog">
<?php
if (isset($_SESSION['ID'])){
echo $Forename." ".$LastName;
echo '<a href="logout.php">Logout</a> / ';
echo '<a href="userpage.html">Account</a>';
}
else {
if (!isset($_SESSION['ID'])){
echo '<a href="login.php">Log In</a> / ';
echo '<a href="register.php">Register</a>';
}
}
?>
</div>
</div>
<div class="center">
<div class="menu">
<ul>
<li ><a href="home.html">Home</a></li>
<li class='active'><a href="attractions.html">Attractions</a>
<ul class="sub-menu">
<li>
<a href="historyv.html">Historical Villages</a>
</li>
<li>
<a href="nature.html">Nature</a>
</li>
<li>
<a href="sr.html">Seaside Resorts </a>
</li>
<li>
<a href="wr.html">Winter Resorts </a>
</li>
<li>
<a href="atimes.html">Ancient Times</a>
</li>
</ul>
</li>
<li><a href="traditions.html">Traditions</a></li>
<li><a href="pictures.html">Pictures</a></li>
<li><a href="about.html">About Us</a></li>
</ul>
</div>
<div class="center1">
<?php
if (!$link = mysql_connect('localhost', 'root', '')) {
echo 'Could not connect to mysql';
exit;
}
if (!mysql_select_db(')) {
echo 'Could not select database';
exit;
}
$sql = "SELECT `AttractionID`,`Name`, `Location`, `Description`, `Airport`, `imglink`, `imglink2` FROM `attractions` WHERE `Category`='HistV'";
$result = mysql_query($sql, $link);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo "<a href='attraction.php?village=" . $row['AttractionID'] . "'>" . "<br />" .
$row['Name'] .
"<br />" .
"<img src='" . $row['imglink2'] . "' height='130' width='150'>
</a>";
}
mysql_free_result($result);
?>
</div>
</div>
</body>
</html>
现在,我的数据库中的项目显示为一个在另一个下面的列表,如下所示。 我如何制作它以便它从列表中显示两个彼此相邻的项目,并在它们下面另外两个,依此类推? 我可以使用任何CSS吗? 感谢
答案 0 :(得分:0)
为什么不使用css nth子属性来定位偶数列表来定位奇数列表,将这样的内容添加到你的css中
ul.submenu {
}
ul.submenu li {
display: inline;
height: 50px;
margin: 20px;
float: left;
}
ul.submenu li:nth-child(odd) {
color: #F00;
clear: left;
}
希望这项工作我已经更新了这里的小提琴,根据您的使用jsfiddle
进行自定义