简体   繁体   English

字段集背景色会影响网站背景色

[英]Fieldset background color affects website background color

I am designing a website where its whole background color is light green (#F5FFF6 to be exact), and now I need to create a fieldset who's background color is white (#FFFFFFF). 我正在设计一个网站,其整个背景颜色为浅绿色 (确切地说是#F5FFF6),现在我需要创建一个背景颜色为白色(#FFFFFFF)的字段集。 My CSS markup is below: 我的CSS标记如下:

#page_content {
width: 100%;
height: auto;
min-height: 100%;
position: relative;
background-color: #F5FFF6;
}

#fieldset {
background-color: #FFFFFF;
}

It kinda worked on the "light-green page background color" and my fieldset's color is white which what I wanted too. 它有点适用于“浅绿色页面背景颜色”,而我的字段集的颜色是白色,这也是我想要的。 But I noticed that the area where my fieldset is positioned, the background color of the page was white too instead of that light-green. 但是我注意到我的字段集所在的区域,页面的背景颜色也是白色,而不是浅绿色。 The rest were all light-green except to that area. 除该区域外,其余所有区域均为浅绿色。 So I tried creating another fieldset and boom! 因此,我尝试创建另一个字段集和繁荣! The same thing happened to the first fieldset - the area behind my fieldset was white again. 第一个字段集发生了相同的事情-我的字段集后面的区域再次变为白色。

I do not understand the exact problem. 我不明白确切的问题。
If you don`t want the whole width of the page to be white just give the fieldset a width and so the background color of the page will remain green. 如果您不希望页面的整个宽度为白色,只需为fieldset设置宽度,这样页面的背景颜色将保持绿色。

#fieldset {
background-color: #FFFFFF;
width: 100px;
height: 150px;    
}

i made an example: http://jsfiddle.net/aKGmc/2/ if this does not help you please upload a jsfiddle with it so i can take a look at the problem 我举了一个例子: http : //jsfiddle.net/aKGmc/2/如果这对您没有帮助,请上传一个jsfiddle以便我可以看一下这个问题

Ids (selectors prefixed with a #) should be unique to one single element. ID(以#开头的选择器)应该对一个元素唯一。
If you want to target more than one element of a category, use a class and the appropriate selector ( <div class="something"> and .something {} ) or a generic selector ( div {} ). 如果要定位一个类别的多个元素,请使用类和适当的选择器( <div class="something">.something {} )或通用选择器( div {} )。

That behavior is normal. 那是正常现象。 You chose to apply the white background to an element (Fieldset) and you got the white background relative to that area. 您选择将白色背景应用于元素(字段集),并获得相对于该区域的白色背景。 So if that is not ok, you probably want to achieve something else. 因此,如果那不行,您可能想要实现其他目标。

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

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