【发布时间】:2011-12-07 10:58:05
【问题描述】:
我在某些 div 的位置和布局方面遇到了问题。
我想要的布局:
我希望标题始终完整显示在右侧。副标题应出现在左侧,但会隐藏任何溢出,因此标题的长度始终优先。
我有以下代码:
<html>
<head>
<style type="text/css">
.title {height: 25px; text-align:left; width: 300px; border:1px solid red;}
.subtitle {height: 20px; overflow:hidden; float:left; border: 1px solid blue;}
</style>
</head>
<body>
<div class="title">
Title number 1
<div class="subtitle">This is subtitle that is longer with even more text</div>
</div>
</body>
</html>
如果字幕太长,它只会悬停在下方。 有什么想法吗?
【问题讨论】:
-
我认为将标题放在左边,副标题放在右边会更有意义。
-
谢谢,但我用“标题”和“副标题”替换了我的真实数据作为示例。不过你是对的,不好的例子!