如何使这个CSS在中间?

时间:2013-04-24 12:29:02

标签: css

我在google.com上找到的CSS有问题 目前在试图证明这个CSS的结果不是中间的.. 我尝试编辑CSS但仍然不能,,,也许是因为我对CSS的了解较少..

它的HTML。

<div class='menu'>
<a href='clearsessions.php'><span>Home</span></a>
<a href='#'><span>Blog</span></a>
<a href='#'><span>Buy Followers</span></a>
<a href='#'><span>Contact</span></a>
</div

CSS

.menu:after, .menu:before {
margin-top:0.5em;
content: "";
float:left;
border:1.5em solid rgba(0, 159, 234, 0.3 );}
.menu:after {
border-right-color:transparent;}
.menu:before {
border-left-color:transparent;
}
.menu a:link, .menu a:visited {
color:#fff;
text-decoration:none;
float:left;
height:3.5em;
overflow:hidden;}
.menu span {
background:rgba(0, 159, 234, 0.3 );
display:inline-block;
line-height:3em;
padding:0 1em;
margin-top:0.5em;
position:relative;
-webkit-transition: background, margin 0.2s;
-moz-transition: background, margin 0.2s;
-o-transition: background-color, margin-top 0.2s;
transition: background, margin 0.2s;
}
.menu a:hover span {
background:rgba(0, 159, 234, 0.5 );
margin-top:0;
}
.menu span:before {
content: "";
position:absolute;
top:3em;
left:0;
border-right:0.5em solid #9B8651;
border-bottom:0.5em solid rgba(0, 159, 234, 0.3 );
}
.menu span:after {
content: "";
position:absolute;
top:3em;
right:0;
border-left:0.5em solid #9B8651;
border-bottom:0.5em solid rgba(0, 159, 234, 0.3 );}

请帮助,, :(

1 个答案:

答案 0 :(得分:0)

您需要将此添加到您的css:

.menu{
    position: relative;
    left: 50%;
    margin-left: -212px;
}

您需要找到准确的margin-left px