2012-05-12 4 views
0

저는 HTML과 CSS를 사용하여 웹 사이트를 코딩했으며, 최근에 배경색이있는 div 요소가 필요했습니다. 나는 background-color: gray;을 넣었지만 작동하지 않았습니다. Chrome의 inspect 요소 기능을 사용했는데 Chrome에서 요소를 인식하지 못한다고합니다. Firefox에서 같은 기능을 사용했는데 CSS 요소를 인식하지 못했습니다. div는 세 개의 부동 섹션을 포함하지만 overflow: auto을 사용하므로 문제는되지 않습니다. 누군가 내 div에 배경색을 추가 할 수없는 이유를 설명 할 수 있습니까?div background-color가 작동하지 않습니다.

HTML은 :

<div id="main"> 
     <header> 
     <h1>LOGO</h1> 
     <nav> 
      <a href="index.html" title="Home">Home</a> 
      <a href="about.html" title="About">About</a> 
      <a href="features.html" title="Features">Features</a> 
      <a href="specs.html" title="Specifications">Specs</a> 
      <a href="updates.html" title="Updates">Updates</a> 
      <a href="contact.html" title="Contact Us">Contact</a> 
     </nav> 
     </header> 

     <section class="left"> 
     <h2>NEWS</h2> 
     <p>Itate eaquid quodit, utem dolorenihit ullore ides est faccum simaiorrum accaerf erfercim voloremod ut volectem con cus, temoluptatur as disquatent.</p> 
     </section> 

     <section class="right"> 
     <h2>SOMETHING</h2> 
     <p>Itate eaquid quodit, utem dolorenihit ullore ides est faccum simaiorrum accaerf erfercim voloremod ut volectem con cus, temoluptatur as disquatent.</p> 
     </section> 

     <section class="right"> 
     <h2>SOMETHING</h2> 
     <p>Itate eaquid quodit, utem dolorenihit ullore ides est faccum 
simaiorrum accaerf erfercim voloremod ut volectem con cus, 
temoluptatur as disquatent.</p> 
     </section> 
    </div> 

CSS : 당신의 CSS의이 부분에서

#main { 
    backgound: gray; 
    layer-background: gray; 
    overflow: auto; 
    border: 2px dashed black; 

    border-radius: 15px; 
    -moz-border-radius: 15px; 
} 

section { 
    background-color: green; 
    text-align: justify; 
    margin: 5px; 
    padding 10px; 

    border-radius: 10px; 
    -moz-border-radius: 10px; 
} 
+3

요소의 HTML과 CSS (선택기 포함)를 게시하십시오. – Bojangles

답변

4

:

#main { 
    backgound: gray; 
    layer-background: gray; 

    /* .. */ 
} 

backgoundbackground해야하고, layer-background는 CSS 속성이 아닙니다.

실수를 수정하면 what you have works입니다.

+0

아, 네 말이 맞아. 나는 너무 부끄럽다. 오타가 날 때마다 얻을 것입니다. 'layer-background'는 내가 인터넷에서 발견 한 바로는 무언가였습니다. – thePurpleMonkey

+0

오타가 때때로 발생합니다. [CSS의 유효성 검사] (http://jigsaw.w3.org/css-validator/)가 도움을 주었을 것입니다. – thirtydot

+1

@thePurpleMonkey [배경색] (http://www.w3.org/TR/CSS2/colors.html#propdef-background-color)는 [배경] (http : // www. w3.org/TR/CSS2/colors.html#propdef-background)에는 범위가 더 넓습니다. 하지만 당신이 사용하는 것은 개인적 취향에 관한 질문이라고 생각합니다. – bostaf

0

배경 맞춤법이 잘못되었습니다. 올바른 철자는 배경 인이며 색상 이름을 사용하는 것이 아닌 16 진 코드를 사용해보십시오.

관련 문제