[英]Padding and margin issue on a simple css template
This is my code: 这是我的代码:
http://jsfiddle.net/spadez/rAQYL/1/ http://jsfiddle.net/spadez/rAQYL/1/
I am trying to achieve three things but I am a bit stuck. 我正在努力实现三件事,但我有些困惑。
Since I used this code I dont know where the space is coming from: 由于我使用了这段代码,所以我不知道空间来自哪里:
* {
padding: 0px;
margin: 0px;
border: 0px;
}
Then to get the 1px space between each list item I used this code but it doesnt seem to work: 然后为了获得每个列表项之间的1px间隔,我使用了这段代码,但它似乎不起作用:
#header ul li {
padding-left: 1px;
}
Can someone who me where I am going wrong please? 有人能帮我解决我的问题吗?
Your additional space is coming from this rule 您的额外空间来自此规则
#header h1, #header ul, #header ul li {
...
background: white;
padding: 5px 12px;
}
See how you're applying padding to ul
and then to li
s within ul
s too? 看看您是如何对
ul
然后在ul
内的li
应用填充的吗? It's adding up. 它加起来。
The same rule is responsible for no green background showing, you're setting the entire ul
s background to white. 相同的规则导致没有绿色背景显示,您将整个
ul
背景设置为白色。
Also try chaning padding-left
on li
s to margin-left
: 还可以尝试将
li
的padding-left
更改为margin-left
:
#header li{
margin-left: 10px
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.