由于容器DIV的背景属性,我遇到了CSS转换无法正常工作的问题。这是我在网上冲浪的一段代码,但找不到我所在的页面,所以我不能回去问他们。这意味着什么,是一个普通的按钮,但当盘旋时,两个段落滑出(一个在顶部,一个在底部)。它本身就可以正常工作,但是当我将它放入容器DIV中,并在容器上放置背景颜色时,它就不再有效了。我Firebugged它发现,当我禁用BG属性时,它可以工作。疯狂的是,过渡是在边缘,而与BG没有任何关系。忍受我,这是我的第一个问题,我将尝试正确插入代码......
#container
{
background: #cf6;
display: inline-block;
height: 500px;
margin: 0 auto;
text-align: center;
width: 700px
}
.download-button
{
margin: 50px auto;
width: 100px;
}
.download-button a
{
background: #003f87;
background: -moz-linear-gradient(top, #003f87 0%, #3063a5 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#003f87), color-stop(100%,#3063a5));
background: -webkit-linear-gradient(top, #003f87 0%,#3063a5 100%);
background: -o-linear-gradient(top, #003f87 0%,#3063a5 100%);
background: -ms-linear-gradient(top, #003f87 0%,#3063a5 100%);
background: linear-gradient(top, #003f87 0%,#3063a5 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#003f87', endColorstr='#3063a5',GradientType=0 );
color: white;
display: block;
font: 17px/50px Helvetica, Verdana, sans-serif;
height: 50px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
width: 200px;
}
.download-button a,
.download-button p
{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
-moz-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}
.download-button p
{
background: #222;
color: #fff;
display: block;
font: 12px/45px Helvetica, Verdana, sans-serif;
height: 40px;
margin: -50px 0 0 10px;
position: absolute;
text-align: center;
-webkit-transition: margin 0.5s ease;
-moz-transition: margin 0.5s ease;
-o-transition: margin 0.5s ease;
-ms-transition: margin 0.5s ease;
transition: margin 0.5s ease;
width: 180px;
z-index: -1;
}
.download-button:hover .bottom
{
margin: -10px 0 0 10px;
}
.download-button:hover .top
{
line-height: 35px;
margin: -80px 0 0 10px;
}
.download-button a:active
{
background: #003f87;
background: -moz-linear-gradient(top, #003f87 36%, #3063a5 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(36%,#003f87), color-stop(100%,#3063a5));
background: -webkit-linear-gradient(top, #003f87 36%,#3063a5 100%);
background: -o-linear-gradient(top, #003f87 36%,#3063a5 100%);
background: -ms-linear-gradient(top, #003f87 36%,#3063a5 100%);
background: linear-gradient(top, #003f87 36%,#3063a5 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#003f87', endColorstr='#3063a5',GradientType=0 );
}
.download-button:active .bottom
{
margin: -20px 0 0 10px;
}
.download-button:active .top
{
margin: -70px 0 0 10px;
}
<div id="container">
<div class="download-button">
<a href="#">Download</a>
<p class="top">click to begin</p>
<p class="bottom">1.2MB .zip</p>
</div>
</div>
答案 0 :(得分:0)
请尝试以下操作: Demo
.download-button a {
z-index: 100;
position:relative;
}
.download-button p {
z-index: 0;
}
<p>
代码边距有negative
z-index值,这就是为什么它落后于#container
bg,现在我将z-index
值更改为积极并为<a>
提供更多z-index
值的位置,以显示在前面