如何讓圖標均勻分佈在模態的寬度上?如何在Bootstrap模式下均勻分佈社交媒體圖標
我有一對社交媒體圖標放在一個模式。目前,他們重疊,這不會使一個很好的經驗,見下圖和代碼示例:
HTML代碼:
.fa {
padding: 12px;
font-size: 18px;
width: 30px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 5px 2px;
}
.fa:hover {
opacity: 0.7;
}
.fa-envelope {
background: #939393;
color: white;
}
.fa-twitter {
background: #55ACEE;
color: white;
}
.fa-linkedin-square {
background: #007bb5;
color: white;
}
.fa-github {
background: #2c4762;
color: white;
}
.fa-stack-exchange {
background: #125688;
color: white;
}
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Give me a shout via..</h4>
</div>
<div class="modal-body">
<p>
<a href="#" class="fa fa-envelope"></a>
<a href="#" class="fa fa-twitter"></a>
<a href="#" class="fa fa-linkedin-square"></a>
<a href="#" class="fa fa-stack-exchange"></a>
<a href="#" class="fa fa-github"></a>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
嘗試.fa {保證金左:0;保證金右:5px的;文本對齊:中心;字體大小:12像素; padding:16px; width:auto} .fa:last-child {margin-right:0} – Super
也許這是因爲你給.fa一個固定的寬度。也許嘗試使用'width:auto;'將會起作用。 – Rubenxfd
輝煌。我看不到所有樹木的森林。感謝@Rubenxfd! – Johnny