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

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条)

报告相同问题?

悬赏问题

  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀
  • ¥15 mifare plus卡认证
  • ¥30 LSTM预测结果是一条直线
  • ¥15 stnodeeditor自定义控件
  • ¥15 SDO如何更改STM32的波特率