Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CSS / Background Colors

Featured Replies

I have a basic CSS problem and I cant quite figure out why.

 

Perhaps someone here can help.

 

Here's the basic HTML & CSS code.

 

<div id="container">
<nav>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<li><a href="#">Link 5</a></li>
</ul>
</nav>
<section>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
<p>Dummy Text</p>
</section>

 

And the corresponding CSS code...

 

div#container {
position: relative;
width: 1000px;
margin: 0;
padding: 0;
background: #111;
}

nav {
position: relative;
display: inline;
width: 400px;
margin: 0;
padding: 0;
background: #222;
}

section {
position: relative;
display: inline;
width: 600px;
margin: 0;
padding: 0;
background: #333;
}

ul {
padding: 0;
margin: 0;
list-style: none;
}

 

The problem is that the div#container background color is not being applied.

 

Any help would be appreciated. Thank you!

  • Author

You haven't closed the container in the code above, so I'd check it in your actual code.

 

Oh sorry, It wasn't a direct copy of my code. The div tag is closed in my code.

  • Author

Actually, I just fixed it with inserting an empty div with a "clear: both;" style right before closing the container div, and that worked.

Edited by Siege84

Those colours are are all blacks. Maybe change colours so you can see the different elements and the text. I don't know why your div#container doesn't show up. Probably a typo.

  • Author

I'm not seeing div#container at all in that copy of your document.

 

Yeah, I changed the <section> to <article> and the <div id="container"> to <section> between my first and second post, and adjusted the CSS accordingly. It was just a cosmetic change to the code, none of the functionality was changed.

 

Those colours are are all blacks. Maybe change colours so you can see the different elements and the text. I don't know why your div#container doesn't show up. Probably a typo.

 

They were all grays. I often use monochrome's when testing just because it's sort of the standard I've become accustomed to. The problem I was having, before appending a <div style="clear: both;"></div> to solve it, was the <div id="container"> (now <section>) was still a #FFFFFF background instead of the one I was setting. It's fine now though.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.