简体   繁体   English

半页全宽样式CSS

[英]half page full width Styling CSS

I am currently working on this website: http://mdftanzania.com . 我目前正在这个网站上: http : //mdftanzania.com I am using Wordpress and headway101. 我正在使用Wordpress和headway101。 I want to have a full width green background color that applies to the begin part of the page: About Us and Services. 我希望将全宽绿色背景色应用于页面的开始部分:关于我们和服务。 I add a div class to the part of the page where the green background has to be. 我将div类添加到必须具有绿色背景的页面部分。 I tried to style the div class to a full width green background, this didn't work out and at the moment only a part is styled now (see the website: http://mdftanzania.com ). 我试图将div类的样式设置为全角绿色背景,但这种方法没有奏效,目前仅对一部分进行了样式设置(请参见网站: http : //mdftanzania.com )。

I understand that there is another solutions, that is creating a container or widget above the container for the content, where I place the first part of the page text in. The problem with this is that it is confusing for my client where to edit the text in the page. 我了解还有另一种解决方案,那就是在内容的容器上方创建一个容器或小部件,将页面文本的第一部分放在其中。问题在于,它使我的客户难以在哪里编辑页面中的文字。 The simplicity of Wordpress goes basically away then. 然后,Wordpress的简单性便基本消失了。 Because of that, I am looking for a solution with CSS styling, so the client is only dealing with the 's. 因此,我正在寻找具有CSS样式的解决方案,因此客户端仅处理。

Does anybody has a solution for this? 有人对此有解决方案吗?

You have this rule set in your css: 您在CSS中设置了以下规则:

.block-type-content {
    padding-left: 25px;
    padding-right: 25px;
    padding-top: 120px;
}

So children of this container, even though they may have a width of 100%, have to obey this padding of their parent. 因此,此容器的子级即使宽度为100%,也必须服从其父级的填充。 That's why you don't get a full width green bar. 这就是为什么您没有获得全宽绿色条的原因。 You might try negative margin-left and right to expand your green bar: 您可以尝试使用负的左右边距来扩展绿色条:

.color {
    margin: 0 -25px;
    padding: 0 25px;
}

At least in Firefox/Mac, this solves your issue. 至少在Firefox / Mac中,这可以解决您的问题。

Since you have predetermined a padding to the content block , it is obviously affecting all the child elements that are contained in it, including the div with green background, which means that you should either remove that padding and apply it only to specific elements, or apply this simple CSS workaround to your div: 由于您已经为内容块预先确定了填充 ,因此显然会影响其中包含的所有子元素,包括具有绿色背景的div,这意味着您应该删除该填充并将其仅应用于特定元素,或者将此简单的CSS解决方法应用于div:

{
    margin: 0 -25px;
    padding: 0 25px;
}

This makes it, in your words, "full width" and applies a padding to its content. 用您的话来说,这使其成为“全宽”,并对其内容应用填充。

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

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