gpt4 book ai didi

twitter-bootstrap - 将 anchor 标签内的内容居中对齐

转载 作者:行者123 更新时间:2023-12-03 22:16:56 25 4
gpt4 key购买 nike

我需要帮助以使 anchor 内的内容垂直对齐。我正在使用 Font Awesome 图标和 anchor 标记内的文本。我希望图标和文本在中心垂直和水平对齐。我能够进行水平对齐,但不能进行垂直对齐。不知道我错过了什么

.my-tile {
height: 90px;
margin-left: 0.5%;
margin-right: 0.5%;
float: left;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 14px;
/*display: table;*/
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
position: relative;
align-items: center;
background: linear-gradient(#af4b17, #e57234); /* Standard syntax */
background: -moz-linear-gradient(#af4b17, #e57234 35%, #e57234);
background: -webkit-gradient(linear,left top,left bottom,color-stop(0, #af4b17),color-stop(.35, #e57234),color-stop(1, #e57234));
border: 1px solid #af4b17;
text-align: center;
justify-content: center;
vertical-align:middle;
}

.my-tile > a {
display: flex;
align-items: center;
justify-content: center;
color: white;
/*padding-bottom: 10px;*/
text-decoration: none;
position: relative;
vertical-align:middle;
}

.my-tile > a .link-icon {
color: white !important;
font-size: 30px !important;
height: 1em;
margin: 0 auto 5px;
width: 1em;
display: block;

}

.my-tile-half {
width: 49%;
}
<script src="https://use.fontawesome.com/releases/v5.0.9/js/all.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>
<link href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-4">
<div class="row">
<div class="col-md-12">
<div class="my-tile my-tile-half">
<a href="#">
<div>
<span class="fas fa-upload link-icon"></span>Upload
</div>
</a>
</div>
<div class="my-tile my-tile-half">
<a href="#">
<div>
<span class="fas fa-clipboard-check link-icon"></span>Done
</div>
</a>
</div>
</div>
</div>
</div>
</div>

最佳答案

对齐内部所有内容的最佳方法<a></a>是使用灵活

a {
display: flex;
align-items: center;
justify-content: center;

/** Use this rule if the tag has a parent with specific height */
height: 100%;
}
查看此演示: https://jsfiddle.net/gkL5of1z/3/

关于twitter-bootstrap - 将 anchor 标签内的内容居中对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49697943/

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