doujuyang1764 2011-06-15 14:58
浏览 172
已采纳

HTML / CSS问题:div的一部分浮动到下一行,我希望它在同一行

I am loading names/grades from a database which happens perfectly... however, the grade assosciated with the person is for some reason getting floated down to the next line and I can't figure out why, as you can see in this picture: http://i.stack.imgur.com/rqhjp.png

I want that number grade to be on the same line, aligned on the right, but I cant figure out why it's getting pushed down to the next line. Here is my php:

echo '<div class = "name">' . $firstname . " "  . $lastname . "<strong>" . '<p align="right">' . $avg . '</p></strong></div>';

And the CSS it refers to:

}

#content .name{
    background: #FFF;
    float:left; 
    width: 220px;
    padding: 0px;
    position: relative;
    margin: 0px;
    font-size: 1.4em;
    border: 2px solid #CCC;
    border-radius: 10px;
}
  • 写回答

3条回答 默认 最新

  • doufendi9063 2011-06-15 15:02
    关注

    Instead of using p and align, put the grade in a span and float it to the right. You can see it working in this fiddle.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?