水平不垂直显示?

时间:2013-12-22 20:12:23

标签: php css

我从sql数据库中取出信息(我知道mysql已被弃用,我很快就会转换)。无论如何,信息会自动垂直显示。相反,我希望它水平显示。

Template.php(部分内容)我必须修复,我确实发现了一些错误。

    <?php 
    $channel_check = mysql_query("SELECT content, Date FROM wgo WHERE Posted_By='$user' ORDER by `id` DESC;");
    $numrows_cc = mysql_num_rows($channel_check);
    if ($numrows_cc == 0) {
    echo ''; // They don't have any channels so they need to create one?><h4> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspYou haven't posted anything yet. You can post what's going on in your life, how you're feeling, or anything else that matters to you.</h4>


 <?php
}
else
{
?>
<div id="recentc">
</div>
<?php
echo"<h2 id='lp'> Latest Posts</h2>";
  while($row = mysql_fetch_assoc($channel_check)) {
  $channel_name = $row['content'];
 ?>
 <div style="margin-top:60px;">
 <hr style="margin-right:340px;width:600px; opacity:0;">

            <?php echo "<div id='rpc'><h6> $channel_name</h6></div>";?>
   </div>

样式:

#rpc {
color:#6E6E6E;
font-size:25px;
margin-left:420px;
font-family:Tahoma, Courier New, monospace;

margin-right:100px;
}

好的,所以我做了所有建议。它更好,但现在看起来非常时髦。这是代码现在的样子。

     <?php
}
else
{
?>
<div id="recentc" style="display:inline-block;">
</div>
<?php
echo"<h2 id='lp'> Latest Posts</h2>";
  while($row = mysql_fetch_array($channel_check)) {
  $channel_name = $row['content'];
 ?>


            <?php echo "<div id='rpc'><h6> $channel_name</h6></div>";?>
   </div>

    #rpc {
color:#6E6E6E;
font-size:25px;
margin-left:420px;
font-family:Tahoma, Courier New, monospace;
display:inline-block;
margin-right:100px;

}

http://i.stack.imgur.com/hautR.png

1 个答案:

答案 0 :(得分:0)

我会在元素中添加一个类,在CSS中使用display:inline-block。你也可以float:left到你的第一个元素。然后你可以为每个元素使用宽度%,这样它们就很灵活。

也不要像&nbsp那样使用{{1}}。只需在CSS中使用填充或边距。