元素的顶部边距(CSS) [英] Top margin of an element (CSS)
本文介绍了元素的顶部边距(CSS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要为元素的顶部设置边距。文字必须在元素内,并且顶部边距为N像素。
I need to set a margin to the top of an element. The text must be within the element and have a top margin of N pixels.
这里是我要实现的:
CSS:
body {
height: 960px;
}
.breadcrumbs {
position: relative;
background-color: #eee;
height: 10%;
}
.name {
color: #000;
margin-top: 50px;
}
感谢。
推荐答案
由于 .breadcrumbs
有 position:relative
c> position:absolute; 到 .name
。
Since .breadcrumbs
has position: relative
, set position: absolute;
to .name
.
- JSFiddle
这篇关于元素的顶部边距(CSS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文