我在 wordpress 中编写了一个循环,循环遍历帖子标题,然后在页面顶部的特殊最新新闻部分中显示前 6 个。问题是我无法将标题拉近,如您在图 1 中所见。我希望这些标题显示为图 2 中所示。
这是我的 HTML 和 PHP 代码:
<div id="freshlyWrapper">
<div id="freshlyposts">
<?php
$freshlyIonised = new WP_Query();
$freshlyIonised->query('category_name=featured&showposts=6');
while($freshlyIonised->have_posts()):
$freshlyIonised->the_post();
?>
<div class="freshlyionisedbox"><h3><?php the_title(); ?></h3></div>
<?php endwhile; ?>
这是 CSS:
#freshlyWrapper {
width: 980px;
text-align: left;
background: #ffffff;
float: left;
}
#freshlyposts {
width: 980px;
margin: 0 auto;
text-align: left;
height: 100px;
color: #000000;
}
.freshlyionisedbox {
position: relative;
float: left;
height: 25px;
margin-left: 140px;
padding: 0px;
top: 3px;
}
#freshlyposts h3 {
width: auto;
font-weight: normal;
letter-spacing: normal;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 13px;
}
.clearboth { clear: both; }
.freshlyionisedbox {
position: relative;
float:left;
height: 25px;
margin-left: 40px;
/*-- try it --*/
padding:0px;
top: 3px;
}
我是一名优秀的程序员,十分优秀!