Results 1 to 3 of 3

Thread: Div not showing background color

  1. #1
    Join Date
    Apr 2015
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Div not showing background color

    i'm very new to css and i'm still trying to get a hang of things work. what i'm trying to do should be simple, but i don't understand why its not working.

    i have a banner div from my code below which i set to have a background color of yellow just so i know its there . i just can't seem to figure out why the div is not displaying. Can anyone please help!!!

    thanks


    HTML Code:
    body {
    	font-family: arial, sans-serif;
    	background-image: url("dark-canvas.gif"); 
    	padding: 0;
    	margin: 0;
    	/* max-width: 100%; */
    }
    
    
    #header {
    	position: fixed;
    	width: 100%;
    	background-color: black;
    	height: 70px;
    	z-index: 10;
    	/*overflow: auto; */
    }
    
    #icons {
    	float: right;
    	padding-right: 10px;
    	}
    
    #banner {
    
    	background-color: yellow;
    	height: 50px;
    	
    }
    HTML Code:
    <html>
    
    <HEAD>
    		
    		<title>My test script</title>
    		<link href="./bukotest.css" rel="stylesheet" type="text/css">
    
    		
    </HEAD>
    
    <BODY>
    <!-- <div id="main"> -->
    
    
    
    	<div id="header">
    		<div>
    			<img src="twitter-icon.png">
    		</div>
    		<div>
    			<img src="twitter-icon.png">
    		</div>
    		<div>
    			<img src="twitter-icon.png">
    		</div>
    		<div id="icons">
    			<img src="twitter-icon.png">
    		</div>
    
    	</div> <! end of header ->
    
    	<div id="banner">
    		<img src="twitter-icon.png">
    	</div>
    
    	
    
    
    </BODY>
    
    
    </html>

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    It's hiding behind your black header

    The reason for this is that the header has a fixed position, which pulls it out of the normal flow of the document. On its own - right at the top of the markup in the body section - it doesn't make much difference, but as soon as other elements are added, the behaviour becomes more obvious. The next element in your markup - yellow banner - acts like it isn't there, and sits in the flow of the web page, which for it is right at the top of the document. The header has a greater height so it covers it (remove the header's background colours and you'll see the yellow banner peeping through.)

    So now you need to decide where to display the yellow banner. If you want it to take up normal flow but have it show under the banner, give it a relative position and place it 70px from the top;
    Code:
    #banner {
    	background-color: yellow;
    	height: 50px;
    	position: relative; 
    	top: 70px;	
    }
    This may or may not be what you want to achieve but I hope it helps explain some of the behaviour and starts you out with learning how positioning works

    More info http://www.barelyfitz.com/screencast...s/positioning/
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    gottijay2000 (04-07-2015)

  4. #3
    Join Date
    Apr 2015
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Talking YaaY it works!!

    Thank you very much! that worked a treat! ....
    the short tutorial was very helpful as well

Similar Threads

  1. Replies: 7
    Last Post: 04-21-2012, 07:47 PM
  2. Replies: 12
    Last Post: 03-21-2012, 11:36 PM
  3. Container Div Background IMG/Color Not Showing
    By dineonyourdesign in forum CSS
    Replies: 1
    Last Post: 12-03-2009, 03:24 PM
  4. Replies: 0
    Last Post: 01-29-2007, 09:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •