我正在为我的菜单编写代码,这次使用CSS为动画和js将类从显示更改为隐藏和半隐藏。 (我还没有开始在js上)居中元素的问题
一些问题我不知道如何解决(变得非常紧张)。
- 为什么顶边距不是0?
- 为什么在div与左边和顶边有一些padding/margin/wtv?
- 如何将链接垂直居中? (我想我需要使用100%,以保持和位置固定和溢出隐藏,因为我需要移动的div屏幕之外)
html,
body {
background: #E6E6E6;
}
.menu {
overflow: hidden;
position: fixed;
height: 100%;
width: 100%;
-webkit-transition: all ease .65s;
-moz-transition: all ease .65s;
-ms-transition: all ease .65s;
-o-transition: all ease .65s;
transition: all ease .65s;
}
.left {
right: 0;
margin-right: 0;
}
.left.bar {
right: 100%;
margin-right: -60px;
}
.left.hidden {
right: 100%;
margin-right: 0;
}
.menu > .links {
color: white;
font-family: sans-serif;
font-size: 2.5em;
font-weight: 500;
text-align: center;
text-transform: uppercase;
}
.menu li {
color: rgba(255, 255, 255, .75);
cursor: pointer;
list-style: none;
padding: 15px;
margin: 5px;
-webkit-transition: all ease 1s;
-moz-transition: all ease 1s;
-ms-transition: all ease 1s;
-o-transition: all ease 1s;
transition: all ease 1s;
}
.menu li:hover {
color: rgba(255, 255, 255, 1);
background: rgba(0, 0, 0, .1);
}
.m1 {
background: orange;
z-index: 8;
}
<div class="menu left m1">
<div class="links l1">
<ul>
<li data-open=".m2">Architecture</li>
<li data-open=".m3">Coding</li>
<li data-open=".m4">Thesis</li>
</ul>
</div>
</div>
下面的答案是正确的,我只是想强调,利润/填充是浏览器默认样式的一部分 - 并且还有更多。查看CSS重置 - http://meyerweb.com/eric/tools/css/reset/上最基本的重置。 – 2014-10-27 18:36:18