我遇到了一些奇怪的問題。在我的代碼中,按鈕css動畫只有在margin-top設置爲125px(對於sim-button類)時纔有效。我想把margin-top縮小到25px,但是動畫不起作用。按鈕動畫僅適用於特定保證金
HTML:
<div class="media" style = "background-color:#000;">
<img class="media__image" src="https://www.offensive-security.com/wp-content/uploads/2012/01/security-risk-assessment-report.png">
<div class="media__body">
<h2>Penetration Report</h2>
<p>Get your hands on our Sample Presentation Report</p>
<div class="sim-button button1" data-toggle="modal" data-target="#getQuoteModal">Download Report</div>
</div>
</div>
CSS:
.media {
display: inline-block;
position: relative;
vertical-align: top;
}
.media__image { display: block; }
.media__body {
background: rgba(41, 128, 185, 0.7);
bottom: 0;
color: white;
font-size: 1em;
left: 0;
opacity: 0;
overflow: hidden;
padding: 3.75em 3em;
position: absolute;
text-align: center;
top: 0;
right: 0;
-webkit-transition: 0.6s;
transition: 0.6s;
}
.media__body:hover { opacity: 1; }
.media__body:after,
.media__body:before {
border: 1px solid rgba(255, 255, 255, 0.7);
bottom: 1em;
content: '';
left: 1em;
opacity: 0;
position: absolute;
right: 1em;
top: 1em;
-webkit-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: 0.6s 0.2s;
transition: 0.6s 0.2s;
}
.media__body:before {
border-bottom: none;
border-top: none;
left: 2em;
right: 2em;
}
.media__body:after {
border-left: none;
border-right: none;
bottom: 2em;
top: 2em;
}
.media__body:hover:after,
.media__body:hover:before {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.media__body h2 { margin-top: 0; }
.media__body p { margin-bottom: 0em; }
.sim-button{
line-height: 50px;
height: 50px;
text-align: center;
margin-right: auto;
margin-left: auto;
margin-top: 125px;
width: 60%;
cursor: pointer;
}
.button1 {
color: rgba(255,255,255,1);
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
position: relative;
border: 1px solid rgba(255,255,255,0.5);
}
.button1 a{
color: rgba(51,51,51,1);
text-decoration: none;
display: block;
}
.button1:hover {
background-color: rgba(255,255,255,0.2);
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
}
感謝提前的幫助。