gpt4 book ai didi

html - 在 CSS 圆圈内居中图标的更好方法

转载 作者:太空宇宙 更新时间:2023-11-04 11:10:44 24 4
gpt4 key购买 nike

我在圆 div 中有一个符号。

http://jsfiddle.net/uqbujck3/

这是最好的方法吗?我听说它可能不可靠

.circle {
border-radius: 50%;
width: 50px;
height: 50px;
line-height: 48px;
padding: 0;
background: #fff;
border: 1px solid #1588cb;
color: #1588cb;
text-align: center;
font-size: 18px;
font-weight: 300;
display: inline-block;
text-decoration:none;
}
<div>
<a href="#" class="circle">A</a>
</div>

最佳答案

与 div text-align 相同,但您可以使用 transform 实现完美对齐。请尝试:

$(document).ready(function() {
$(".circle").animate({
width:'200px',
height:'200px'
},2000)
})
.circle {
border-radius: 50%;
width: 50px;
height: 50px;
line-height: 48px;
padding: 0;
background: #fff;
border: 1px solid #1588cb;
color: #1588cb;
font-size: 18px;
font-weight: 300;
position:relative;

}
.a-text{
position: absolute;
text-decoration:none;
top:50%;
left:50%;
transform: translateX(-50%) translateY(-50%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="circle">
<a href="#" class="a-text">A</a>
</div>

关于html - 在 CSS 圆圈内居中图标的更好方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33650587/

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