gpt4 book ai didi

css - 居中文本链接按钮

转载 作者:太空宇宙 更新时间:2023-11-03 21:34:55 25 4
gpt4 key购买 nike

我试图让一个文本链接居中,但是,它没有响应 text-align: center;

有什么想法吗?我知道我想多了..

HTML:

    <div class="container">
<div class="promotion-left">&nbsp;
</div>
<div class="promotion-right">
<h2 class="instructions-head">INSTRUCTIONS</h2>
<ol class="instructions-list">
<li class="instructions-item">INSTRUCTIONS 1</li>
<li class="instructions-item">INSTRUCTIONS 2</li>
<li class="instructions-item">INSTRUCTIONS 3</li>
</ol>
<a href="#" class="promotion-btn">Download</a>
</div>
</div>

CSS:

.promotion-left {
background: white;
display: inline-block;
width: 15%;
}
.promotion-right {
background: #eaf8fe;
display: inline-block;
width: 80%;
}
a.promotion-btn {
background: red;
display: inline-block;
text-align: center;
text-decoration: none;
border-radius: 2px;
padding: 8px 16px;
}

JSFIDDLE

最佳答案

一种选择是使 a 成为具有固定宽度和 auto 边距的 block 元素:

a.promotion-btn {
/* other styles */
display: block;
width: 100px;
margin-left: auto;
margin-right: auto;
}

另一种方法是将 a 放在带有 text-align: center 的 div 中:

<div class="center">
<a href="#" class="promotion-btn">Download</a>
</div>

.center {
text-align: center;
}

关于css - 居中文本链接按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27208031/

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