[英]How to animate 2 elements on scroll from side to center then back to side
[英]How to center 3 imgs side by side?
我正在嘗試並排放置3個社交媒體圖標。 但不知道該怎么做。
<div class="maintext flipInX animated">
<div class="socials wow bounce animated" data-wow-delay="1s">
<a href="www.facebook.com"> <img src="http://s33.postimg.org/yitnj0vbz/fblogo.png"/></a>
<a href="www.github.com"> <img src="http://s33.postimg.org/r7peysh3z/github.png"/></a>
<a href="www.linkedin.com"> <img src="http://s33.postimg.org/lq7vvi8wv/linkedin_3_32.png"/></a>
</div>
</div>
使用text-align: center
.socials { text-align: center; }
<div class="maintext flipInX animated"> <div class="socials wow bounce animated" data-wow-delay="1s"> <a href="www.facebook.com"> <img src="http://placehold.it/50"/></a> <a href="www.github.com"> <img src="http://placehold.it/45"/></a> <a href="www.linkedin.com"> <img src="http://placehold.it/50"/></a> </div> </div>
將<a>
放在.socials
div inline-block
元素內,該元素賦予其與文本相同的屬性。 然后,將text-align:center
添加到父級(即.socials
div)。
添加以下給定的CSS以使其居中
.socials{
text-align:center;
}
.socials a{
display:inline-block;
}
UPDATE
@LGSon在他的評論中提到,
當父級具有
text-align: center
時,無需將inline元素設置為inline-block
即可text-align: center
您只需添加以下給定的CSS以使其居中。
.socials{
text-align:center;
}
但是,請記住,如果需要使用上述方法將任何塊級元素的顯示設置為inline-block
則必須將其設置為inline-block
。
Flexbox非常適合在水平和垂直方向上居中放置內容:
img { height:40px; width:40px; background-color:gray } .socials { display: flex; justify-content:center; } .socials img { flex: 1 auto; }
<div class="maintext flipInX animated"> <div class="socials wow bounce animated" data-wow-delay="1s"> <a href="www.facebook.com"> <img /></a> <a href="www.github.com"> <img /></a> <a href="www.linkedin.com"> <img /></a> </div> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.