简体   繁体   中英

How to change the background color of a div in HTML/CSS

I have been trying to figure out how to change the background color of 2 divs but had it right the first time I believe. My code is as follows,

.maincontentrow {
    width: 960px;
    background-color:#999;
}

The Rest of my code:

The problem I am having is I am using Dreamweaver and the background color change shows up in design mode but not in live mode or when I run it from the browser. I've Googled this high and low and it appears my code is correct. It just wont show the color change in live or in browser. But It does show the change in design mode.

Any ideas on what I am doing wrong or what I can do to fix it? Thanks!

I think you haven't added any element inside the div. Place some text inside it or add height: 50px; in CSS

Try background : #999; or background-color:#999999 or background-color:rgb(153,153,153);

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