css - 如何垂直对齐 :bottom 2 floated divs with text

标签 css position vertical-alignment

我对 CSS 有疑问。我创建了这个 jsfiddle 来展示它 - https://jsfiddle.net/5k92h026/19/

我的代码是:

.left {float:left}
.wrapper{width:690px;}
.first-div {background-color:red;width:334px;height:84px;}
.second-div {
    background-color:blue;
    width:300px;
    height:84px;
    padding:33px 20px 35px 23px;
}
#first-link {
    padding-right:10px;
    display:block;
    float:left;
    vertical-align:bottom;
}
#second-link {
    padding-left:10px;
    display:block;
    float:left;
    border-left: 1px solid black;
    width:50%;
}
<div class="wrapper">
    <div class="left first-div">some info</div>
    <div class="left second-div" style=" display:inline-block;">
            <div class="search-info"></div>
            <a id="first-link" href="">some text here</a>
            <a id="second-link" href="" class="">some text that goes in 2 rows here</a>
    </div>
</div>

我希望蓝色 div 中第一个链接的文本是“some text here”是 vertical-align:bottom,这样它将被定位为第二个链接。当两个链接在一行中时没有问题,但是当第二个文本较长时,它会换行并且它们的位置不好。 怎么做?谢谢。

最佳答案

您可以使用 display:inline-block; 代替 float:left; 并给 vertical-align: bottom; #second-link#first-link。不要forget to remove the extra spaces这是由 display:inline-block;

发生的

Jsfiddle

关于css - 如何垂直对齐 :bottom 2 floated divs with text,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33843703/

相关文章:

CSS 未在 mozilla chrome 中显示

html - 网页上的大可点击区域

html - 水平对齐两个 div(一个在容器的最左边,另一个在容器的最右边)

java - 在多显示器系统中识别正在运行的显示器小程序

css - 如何使 div 在保持其垂直位置的同时与父级的右侧对齐?

html - 使用 CSS 垂直对齐 <a> 元素中的文本

html - 在 css 中声明的图像未显示

css - 在导航链接之后定位内联 block "Triangle"

html - CSS - 溢出和定位

css - 垂直对齐文本和图像(图像顶部到文本 x 高度,图像底部到第 7 行基线)