我的網站上有一個標題,需要右側有一些圖標。我不知道該怎麼做,因爲圖標的位置正確,但div不會展開給它們,這應該是默認行爲。使標題與右側對齊的圖標HTML/CSS
下面是HTML:
<!DOCTYPE html>
<html>
<head>
<title>Kingdom Hearts 358/2 Days HD</title>
<link rel = "stylesheet" type = "text/css" href = "style.css">
</head>
<body>
<div id = "socialMediaHeader">
<div id = "socialMediaIcons">
<a href = "http://twitter.com/kh_days_hd"><img class = "socialMediaIcon" src = "twitter_icon.png"></a>
<a href = "https://www.youtube.com/channel/UC4mVq6c8YpYOuiTwuzejgDw"><img class = "socialMediaIcon" src = "youtube_icon.png"></a>
</div>
</div>
</body>
</html>
這裏是CSS:
* {
margin: 0;
padding: 0;
}
#socialMediaHeader {
background-color: black;
}
.socialMediaIcon {
margin: 10px;
}
#socialMediaIcons {
position: absolute;
right: 0px;
}
#socialMediaIcons::after {
content : "";
display : block;
clear : both;
}
編輯:此代碼是在我正在進行的工作試圖解決這個問題,忽略任何愚蠢的錯誤
把它放在小提琴手上。所以我們可以看到你錯在哪裏。乾杯! –