我是網絡開發新手,我正在爲我的朋友製作一個網站。我想要做的是將他們的coverart放在他們的soundcloud播放列表上,並且這兩個div的大小相同,並且在頁面上垂直和水平居中。我搜索了谷歌和stackoverflow的所有,但沒有答案一直爲我工作。 div繼續顯示在頁面的右下角。我似乎無法做到。如何讓我的div完全居中?
#playlist {
\t \t position: absolute;
\t \t top:50%;
\t \t left:50%;
\t \t width:500px;
\t \t height:500px;
\t \t margin-top: -250px
\t \t margin-left: -250px;
\t \t z-index:1;
\t \t margin: 0 auto;
}
\t #artwork {
\t \t position:absolute;
\t \t top:50%;
\t \t left:50%;
\t \t width:500px;
\t \t height:500px;
\t \t margin-top:-250px;
\t \t margin-left -250px;
\t \t z-index:2;
\t \t margin: 0 auto;
background-color:red; /*only to show hover*/
\t
}
\t #artwork:hover {
\t opacity:0;
}
\t #container{
\t
position: relative;
height:500px;
width:500px;
top:0;
bottom: 0;
left: 0;
right: 0;
}
<!doctype html>
<html>
<head>
<title>VOUDOUX</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body style="background-color:black">
<div id="container">
\t \t <div id="playlist">
\t \t <iframe width="100%" height="100%" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/125549903&color=ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false"></iframe>
\t \t </div>
\t \t <div id="artwork"><img src="images/Vices2.jpg" alt="coverart" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
非常翔實!這正是我需要的! –