我想讓我的4個社交圖片(alt=test
)位於我div的中心(現在他們出現在頂部中心)。我把放在.socials
,但它不工作。我也試圖把它放在.socialdivs
,但它也不起作用。 HTML和CSS代碼如下。文本對齊:中心不適用於社交div
.socials {
width: 100%;
background-color: #5e6066;
text-align: center;
}
.socialdivs {
width: 100%;
margin: auto;
}
.fb {
display: inline-block;
width: 250px;
height: 155px;
margin: auto;
}
.fb:hover {
background-color: #4668b3;
}
.lin {
display: inline-block;
width: 250px;
height: 155px;
margin-top: auto;
}
.lin:hover {
background-color: #00a0dc;
}
.insta {
display: inline-block;
width: 250px;
height: 155px;
margin: auto;
}
.insta:hover {
background-color: #405de6;
}
.golden {
display: inline-block;
width: 250px;
height: 155px;
margin: auto;
}
.golden:hover {
background-color: #fcbf17;
}
.info {
margin-left: auto;
margin-right: auto;
text-align: center;
padding: 20px;
}
<footer>
<div class="socials">
<div class="socialdivs">
<div class="fb">
<a href="https://www.facebook.com" target="_blank"><img src="img/facebook.png" alt="test" /></a>
</div>
<div class="lin">
<a href="https://www.linkedin.com" target="_blank"><img src="img/linkedin.png" alt="test" /></a>
</div>
<div class="insta">
<a href="https://www.instagram.com" target="_blank"><img src="img/instagram.png" alt="test" /></a>
</div>
<div class="golden">
<a href="https://www.goldenline.pl" target="_blank"><img src="img/goldenline.png" alt="test" /></a>
</div>
<div style="clear:both"></div>
</div>
</div>
<div class="info">
Adrian © 2017 Thank you for your visit!
</div>
</footer>
任何幫助,將不勝感激。
「text-align」僅適用於「inline」或「inline-block」元素。 html div默認爲「block」。 –
這個東西會在你的案例**頂端:50%;位置:相對; **把這個CSS放在錨標籤,看看會發生什麼 – LSKhan