【发布时间】:2015-01-04 00:59:11
【问题描述】:
我试图将我的 div .down-arrow 水平居中,但没有成功。 DIV 是绝对定位的,但 margin:0px 自动;似乎没有工作。问题是什么?谢谢 http://jsfiddle.net/7UNrP/
HTML:
<header>
<div class="down-arrow">arrow</div>
</header>
CSS:
header {
position: relative;
width: 100%;
height: 600px;
min-height: 300px;
margin-right: auto;
margin-left: auto;
background-image: url('http://lorempixel.com/output/nature-q-c-1020-711-1.jpg');
background-size: cover;
background-position: center center;
background-color: rgb(222, 222, 222);
}
.down-arrow {
position: absolute;
margin:0px auto;
bottom: 20px;
display: inline;
padding: 10px;
color: #FFF;
border: 0;
font-weight: 400;
font-size: 12px;
background: red;
-webkit-animation: icon 1.2s infinite;
}
@-webkit-keyframes icon {
from {
opacity: 1;
bottom: 20px;
}
to {
opacity: 0;
bottom: 10px;
}
}
【问题讨论】: