css - 如何设置一个部分的 p margin

标签 css

super 基础的问题,我是 CSS 新手...

在我的样式表中我有:

  #topheader {
        position: absolute;
        width: 100%;
        height: 100px;
        background-color: #D1E6DA;
        font-size: 200%;
}

如何添加:

p {
    margin: 20px;
}

在#topheader 内(不是整个页面)?

最佳答案

#topheader p{
    margin: 20px;
}

看到 #topheaderp 之间的空格了吗?这意味着 p 在顶部。

您需要保留 #topheader { } 原样,并添加另一个带有 p 的代码,如我上面所写。

因此您将拥有以下内容:

#topheader {
    position: absolute;
    width: 100%;
    height: 100px;
    background-color: #D1E6DA;
    font-size: 200%;
}
#topheader p{
    margin: 20px;
}

关于css - 如何设置一个部分的 p margin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26077076/

相关文章:

jquery - Bootstrap 移动菜单调整到桌面

html - 图像悬停的猫头鹰轮播 div 高度

html - 如何在一个 html 文件中处理不同语言的同一文档的并行 View ?

CSS :not selector

css - 如何根据父div中子div的数量设置div的高度

html - 选择选项中的 Font Awesome 图标

html - 可以让一个人一个帐户的网站吗?

jquery - 如何更改 Logo 和 slider 之间的高度

php - 一个js文件在另一个php文件中的Javascript : calling document. ready()函数

javascript - 下拉选择表单在 Internet Explorer 中不起作用