简体   繁体   English

(CSS-spanS-rowS)如何居中所有模块名称并使背景跨整个页面宽度

[英](CSS-spanS-rowS) How to center all module names and make background span entire width of page

I recently got a Ning account. 我最近有一个Ning帐户。 I want to customize the site a bit more using their "Add Custom CSS" option I would like the ning site to look as close to this site as possible. 我想使用其“添加自定义CSS”选项对网站进行更多自定义,我希望Ning网站看起来尽可能靠近此网站 More specifically the green horizontal bar across the top of the page, and the location and spacing of the header group. 更具体地说,页面顶部的绿色水平条以及页眉组的位置和间距。 I'm currently using the following CSS on the ning site but can't figure out how to make the green horizontal bar span the entire width of the page. 我目前在ning网站上使用以下CSS,但无法弄清楚如何使绿色的水平条跨越页面的整个宽度。 Any help, advise or direction would be greatly appreciated. 任何帮助,建议或指导将不胜感激。

.mainTab-item.active, .mainTab-item.active > a {
    color: #00a6ed;
}
.site-header {
    height: 0px;
}
.header-container {
    margin-bottom: 15%;
}
h2.module-name {
background-color: #88C540;
    color: #FFFFFF;
    font-size: 16px;
    margin-top: -15%;
    max-width: 100%;
    padding: 30px;
    text-align: center;
    text-shadow: 2px 2px 0px #609F16;
}

Here is the Commonly used CSS classes and HTML (ning.com/ning3help/commonly-used-css-classes-and-html) 这是常用的CSS类和HTML(ning.com/ning3help/commonly-used-css-classes-and-html)

The problem here is that your container has a width of 960px which the green bar is included inside. 这里的问题是您的容器的宽度为960px,其中的绿色条包含在其中。 Therefore when you set max-width or width of 100% it is relative to the container. 因此,当您将最大宽度或宽度设置为100%时,它是相对于容器而言的。 Eg 100% of 960px is 960px. 例如960px的100%是960px。

The only way around this would be to change the mark-up and take it out of .container in order for the percentage to be relative to the document. 唯一的解决方法是更改​​标记并将其从.container中取出,以使百分比相对于文档相对。

Or another option is to absolutely position the div to take it out of the document flow. 或者另一个选择是绝对定位div,以将其从文档流中删除。 But I strongly do not advise that. 但我强烈不建议这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM