-1

The HTML div for the navigation bar design in CSS will not work.

CSS

/* CSS Document */

*{
    margin: 0px;
    padding: 0px; 
}

.clear {
    clear:both;
    height:0px; 
}

body {  
    background:url(../images/bg.jpg) no-repeat scroll center top #13120d;   

    margin: 0;  
    padding: 0;     
    font-family: Tahoma;
    font-size: 13px; 
}   

#header_menu_bg {
    background: url('../images/navigation.png') no-repeat center top;
    height: 198px;  
    width: 737px; 
}

This is just a short example.

HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <meta name="robots" content="index, follow"/>
        <meta name="keywords" content="bla"/>
        <meta name="description" content="bla"/>
        <title>WEBSITE</title>

        <link rel="stylesheet" type="text/css" href="styles/main.css"/>
        <link rel="shortcut icon" href="favicon.png"/>
    </head>
    <body>
        <div id="header_menu_bg">

Any help will be much appreciated!

Aniket
  • 8
  • 2
D3XT3R
  • 1
  • 1
  • 6

6 Answers6

1

You need to assign it a width attribute.

#header_menu_bg {
background: url(../images/navigation.png) no-repeat center top;
height: 280px;
width: 200px; }

EDIT

Check in the console log, to see if there are issues with the browser finding your image. Perhaps you have the wrong path.

EDIT 2

Close your <body> and <div> tags.

carterh062
  • 190
  • 10
1
  1. Make sure the URL to your image is correct.
  2. Place the URL in between ' or " tags (url("../images/navigation.png"))
  3. Add a width to your div, f.e. width: 200px;

EDIT: When looking at your full HTML, you also need to close your <body> and <html> tags.

Your full code will look like this:

HTML:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="robots" content="index, follow"/>
    <meta name="keywords" content="bla"/>
    <meta name="description" content="bla"/>
    <title>WEBSITE</title>

    <link rel="stylesheet" type="text/css" href="styles/main.css"/>
    <link rel="shortcut icon" href="favicon.png"/>
</head>
<body>
    <div id="header_menu_bg"></div>
</body>
</html>

CSS:

*{
    margin: 0px;
    padding: 0px; 
}

.clear {
    clear:both;
    height:0px; 
}

body {  
    background-color: #13120d;  
    margin: 0;  
    padding: 0;     
    font-family: Tahoma;
    font-size: 13px; 
}   

#header_menu_bg {
    background: url('http://placehold.it/737x198') no-repeat center top;
    height: 198px;  
    width: 737px; 
}

DEMO: JSBin (JSFiddle doesn't seem to work at the moment)

Pieter VDE
  • 2,195
  • 4
  • 25
  • 44
0

Assuming you have referenced the css file correctly and no error in your html coding structure I suggest clearing your browser cache.

Bashabi
  • 696
  • 1
  • 12
  • 40
0
background: url(../images/navigation.png) no-repeat center top;

you need "" or '' like this:

background: url('../images/navigation.png') no-repeat center top;

probably this helps you

gsiradze
  • 4,583
  • 15
  • 64
  • 111
0

The following css works and puts an image in the DIV. Fiddle is not working at the moment and I can't put a link for it now.

#header_menu_bg 
{
    background-image: url('fnordware.com/superpng/pngtest16rgba.png'); 
    height: 32px; 
    width: 32px; 
}

You either have a wrong url or something else is wrong if this css doesn't work for you.

rageit
  • 3,513
  • 1
  • 26
  • 38
0

Try this :

Download the sample image from Here and save it as bg.jpg.

Create a new folder and put the 2 below files & a image in same folder.

HTML (index.html)

<!DOCTYPE html>   
<head>
   <title>WEBSITE</title>
   <link rel="stylesheet" type="text/css" href="main.css"/>        
</head>
<body>
    <div id="header_menu_bg">
</body>
</html>

CSS (main.css)

body 
{     
background-color: #13120d;  
margin: 0;  
padding: 0;     
font-family: Tahoma;
font-size: 13px; 
}

#header_menu_bg
{
background: url('bg.jpg') no-repeat center top;
width: 280px;  
height: 500px; 
}

RESULT:

enter image description here

Yuva Raj
  • 3,881
  • 1
  • 19
  • 30