我使用DIV容器position:absolute
,但主容器position:realite
爲做效果。
#maincontainer{
position:relative;
}
#container{
position:absolute;
top:50px;
left:10px;
background-color:#0000FF;
}
h1 {
color:#FFFFFF;
}
.btn {
display:block;
background: #3498db;
background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
background-image: -moz-linear-gradient(top, #3498db, #2980b9);
background-image: -ms-linear-gradient(top, #3498db, #2980b9);
background-image: -o-linear-gradient(top, #3498db, #2980b9);
background-image: linear-gradient(to bottom, #3498db, #2980b9);
-webkit-border-radius: 28;
-moz-border-radius: 28;
border-radius: 28px;
font-family: Arial;
color: #ffffff;
font-size: 20px;
padding: 10px 20px 10px 20px;
text-decoration: none;top:590px;
}
.btn:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
的例子:fiddle
你嘗試過什麼CSS? – Jhecht 2015-02-12 01:37:27
@Jhecht我嘗試了頂部:150px在.btn移動按鈕,但位置不變。在CSS中也使用txt代替h2,因爲文本和按鈕位於容器中,所以它應該是藍色的,但它不起作用 – user3754676 2015-02-12 01:45:45