Html 将两个内联块div与内容对齐
我有两个内联块div,每个块的宽度为其父块的50%,它们正确地显示在彼此旁边。但是,当我添加到其中一个div的链接时,在第二个div的顶部有一个间隙Html 将两个内联块div与内容对齐,html,css,Html,Css,我有两个内联块div,每个块的宽度为其父块的50%,它们正确地显示在彼此旁边。但是,当我添加到其中一个div的链接时,在第二个div的顶部有一个间隙 <div class="wrap"> <div class="resizable resizable1"> <a href="#" class="link1">link1</a> <a href="#" class="link2">link2</a>
<div class="wrap">
<div class="resizable resizable1">
<a href="#" class="link1">link1</a>
<a href="#" class="link2">link2</a>
</div><!--
--><div class="resizable resizable2">second</div>
</div>
.wrap {
width: 100%;
font-size: 0;
}
.resizable {
width: 50%;
height: 120px;
background-color: coral;
display: inline-block;
}
.resizable2 {
background-color: lightblue;
}
.resizable a {
font-size: 12px;
}
JSFIDLE示例
如何对齐两个div?使用显示时:内联块元素默认设置为基线,而不是设置垂直对齐:顶部
使用“显示:内联”块元素时,默认情况下设置为“基线”,而不是设置“垂直对齐:顶部”
您也可以将它们都向左浮动,它们将在包装器中相邻对齐
.wrap {
width: 100%;
font-size: 0;
}
.resizable {
width: 50%;
height: 120px;
background-color: coral;
display: inline-block;
float:left;
}
.resizable2 {
background-color: lightblue;
float:left;
}
.resizable a {
font-size: 12px;
}
您也可以将它们都向左浮动,它们将在包装器中相邻对齐
.wrap {
width: 100%;
font-size: 0;
}
.resizable {
width: 50%;
height: 120px;
background-color: coral;
display: inline-block;
float:left;
}
.resizable2 {
background-color: lightblue;
float:left;
}
.resizable a {
font-size: 12px;
}
我觉得很好,你能解释一下你看到了什么吗也许截图会有帮助我觉得很好,你能解释一下你看到了什么吗也许截图会help@Carlo是的,这是一个垂直对齐问题,我会在我的post@Carlo是的,这是一个垂直对齐问题,我会在我的帖子中更新语言