2014-01-07 43 views
-1

我试图格式化DIV中的文本,但是我也想对DIV进行样式设置。CSS在输入样式文本时没有正确设计DIV

在PHP页面我有DIV和文本:

<div id="main-content"> 
    <h1>Welcome to the Drug Debate!</h1> 
    <p>Home of facts and deabtes of legal and illegal drugs!The Drug debate offers a safe and relaxed enviroment where you will be able to find information and facts about different types of drug </p> 
</div> 

然后在我的CSS我想的风格,DIV使用:

#main-content{ 
background-color: #FFFFFF; 
width:600px; 
height: 350px; 
margin: 0 auto; 
border:solid; 
} 

<h1>和使用<p>

h1 { 
font-family:"Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif; 
font-size:24px; 
padding-left:200px; 

} 

(以及类似的<p>

这是造成问题的原因,比如DIV的背景颜色不适用于文本背后?

(请记住我是很新的编码,这个网站!)

+1

'#FFF'或'#FFFFFF'指的是白!改变颜色请参阅[这里](http://jsfiddle.net/RRH7G/1/) –

+0

这可能是因为你将白色背景应用到你的'h1'和你的'div'。 #FFFFFF是白色的颜色值,你可以在这里发现十六进制颜色http://www.colorpicker.com/ – Luke

+1

白色,白色,美丽。就像那样会显示。 –

回答

0

default background color property is transparent,这就是为什么你看到从通用选择未来通过的背景色。只需将background-color:inherit;添加到您的CSS。

h1, p { 
    font-family:"Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif; 
    font-size:24px; 
    padding-left:200px; 
    background-color:inherit; 
} 

jsFiddle example