[英]top margin doesn't work
I have a little problem with margin top for children element. 我对children元素的margin top有一点问题。
CSS: CSS:
body {
height: 960px;
}
.breadcrumbs {
position: relative;
background-color: #eee;
height: 10%;
}
.name {
color: #000;
margin-top: 50px;
}
http://jsfiddle.net/GRQNh/ http://jsfiddle.net/GRQNh/
Why it doesn't work? 为什么不起作用? Class .name sticky on top.
类.name粘在顶部。
Thanks in advance. 提前致谢。
In your example you are using <span>
and <span>
is not block element, so you need either display: block
or display: inline-block
on it for margin to work. 在您的示例中,您使用的是
<span>
并且<span>
并不是block元素,因此您需要在其上使用display: block
或display: inline-block
来保证页边空白。
If you add display: block
to <span>
then you can use <div>
instead because the effect is the same. 如果将
display: block
添加到<span>
则可以使用<div>
因为效果相同。
This is how it works: 它是这样工作的:
.name{
display:block;
padding-top: 50px;
color: #000;
}
Try to add in class .name
attribute display:inline-block;
尝试添加类
.name
属性display:inline-block;
that should help 那应该有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.