h1
当我在标签上方添加标签时,有未知空间p
。
这是小提琴
我需要的是在下图中
经过考虑float:left
,我在真实页面中尝试过,但仍然出现问题
这是新的代码float:left
那是因为你给你的thumb
班级(这是你的形象)一个 100 像素的高度。只需删除该高度即可修复它,请参阅小提琴:http: //jsfiddle.net/CKRNs/4/
编辑:正如你也说过你想要p
图像旁边的标签,添加float: left
标签p
和thumb
类,如下所示:http: //jsfiddle.net/CKRNs/6/
用于浮动和移除display inline-block;
p {
width: 80%;
vertical-align: top; margin:0
}
h1{
font-size:14px;
margin:0;
vertical-align:top;
}
.thumb{
float:left;
height:100px
}
问题:错误使用display:inline-block;
解决方案:删除所有display:inline-block;
和出现vertical-align:top;
并给出.thumb
float:left;
(对齐块元素的正确方法彼此相邻)。
示例:http: //jsfiddle.net/CKRNs/9/
float:left;
在p
,h1
和.thumb
定义中添加一个。
你需要设置你的形象float:left
。看这个演示:http: //jsfiddle.net/CKRNs/14/
.thumb{
display:inline-block;
height:100px;
float:left;
}
这意味着图像将向左浮动并允许文本换行
我会为拇指使用绝对位置。并将 margin-left 放在 h1 和 p 标签上。http://jsfiddle.net/CKRNs/13/
h1, p{
margin: 0 0 0 60px;
}
.thumb{
position:absolute;
width:50px;
height:50px;
}