gpt4 book ai didi

html - 如何 float 两个 anchor 链接,水平和垂直对齐文本?

转载 作者:行者123 更新时间:2023-11-28 12:43:16 25 4
gpt4 key购买 nike

为了更好地解释,这是我试图实现的图像

enter image description here

我正在处理的是:

You can see the live example of what I'm trying to copy for better explanation .

Here's my code and fiddle

<div class="holdmetight">
<div class="prev"><a href="/">TITLE OF PREVIOUS POST HERE</a></div>
<div class="next"><a href="/">TITLE OF NEXT POST HERE</a></div>
</div>

.holdmetight {width:100%; max-width:1023px; position:relative; display:block; }
.next, .prev { min-height:35px; height:100%; text-align:center; height:100px;}
.prev { display:block; background:#CCC; width: 100% auto; }
.next {float:left; border-right:1px solid #eceff0; background: #AAA;}

最佳答案

这是一个带有display: table 的基本布局。

display: table 的好处:

  • 使用 vertical-align: middle

  • 轻松将文本垂直居中
  • 两个 div 根据其他内容保持相同的高度

Have an example!

HTML/CSS

.holdmetight {
display: table;
border: solid 1px #000;
border-top: solid 2px #000;
}

/* the > selector targets direct div children of .holdmetight */
.holdmetight > div {
display: table-cell;
vertical-align: middle;
background: #aaa;
padding: 10px;
text-align: center;
width: 50%;
}
.prev {
border-right: solid 1px #000;
}
<div class="holdmetight">
<div class="prev">
<a href="/">
TITLE OF PREVIOUS POST HERE.
This is a particulary long title
that will push both divs down.
</a>
</div>
<div class="next">
<a href="/">
TITLE OF NEXT POST HERE
</a>
</div>
</div>

关于html - 如何 float 两个 anchor 链接,水平和垂直对齐文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25946556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com