简体   繁体   中英

CSS style doesn't apply to container div

CSS style works (as far as I can see) for all elements except the container div. I can't get it to work, I have tried everything. It should have width and height and a black background color. This is the code that doesn't apply :

#container {
    width: 588px;
    height: 617px;
    background-color:#000;
    margin: auto;    
}

The code seems right. Both CSS and HTML have passed the w3c validators.

Please help, I'm clueless. Thank you.

right now, looking at the html of your page, you have set the container tag as a class. You need to set it either as a div id, or change it to a class in the css.

so in the code above, simply change the # to a . (period) in front of container

.container {   /* replaced # with a period */
    width: 588px;
    height: 617px;
    background-color:#000;
    margin: auto;    
}

你的容器是一个class而不是一个id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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