【发布时间】:2016-01-10 20:07:41
【问题描述】:
我正在尝试对齐文本块,使其看起来像在图像中。但是,没有可接受的结果。文本位于重复的浮动 div 中。相同的分区彼此相邻。
我的 HTML 代码:
<div id="bottomPanel">
<div class="bottomItem">
<img src="image.png" alt="mouse" class="imgBottom">
<a href="#" title="description" class="item_bottomDesc">Lorem ipsum dolor sit amet</a>
<p class="item_bottomAbout">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur gravida, massa ut suscipit suscipit, massa elit sollicitudin eros, nec lacinia neque odio a est. Phasellus tincidunt nulla eget lorem sodales</p>
</div>
</div>
我的 CSS 代码:
#bottomPanel {
float: left;
width: 100%;
text-align: center;
}
.bottomItem {
float: left;
width: 100%;
margin-top: 10px;
background-color: #e6e6e6;
}
.imgBottom {
float: left;
padding-top: 25px;
padding-left: 14px;
}
.item_bottomDesc {
float: left;
font-family: Arial;
font-weight: bold;
font-size: 12px;
text-decoration: none;
color: #133855;
padding-top: 42px;
padding-left: 18px;
display: block;
}
.item_bottomAbout {
float: left;
font-family: Arial;
font-size: 12px;
width: 376px;
height: auto;
text-align: justify;
display: block;
padding-top: 50px;
color: #7b7a79;
}
元素应该是这样的:
我无法正确对齐的文本是长文本。 分区有 100% 的宽度,大约是 100%。 774 像素。 bottomPanel 是所有浮动 .bottomItem 所在的 div。 有什么想法吗?
【问题讨论】:
标签: html css css-float css-position text-align