0

This has been driving me mad for hours. Please someone explain to me why no image is appearing at all. I'm using XHTML 1.0 strict. Many thanks.

CSS:

#flags {
    position: relative;
    background-image:url(example.png);
    background-repeat: no-repeat;
    float: right;
    margin-left: 18px;
    width:400px;
    height:400px;
} 

HTML:

<div id="flags">
   <p>text
     <br />
       text
     <br/>
   </p>

   <ul>
       <li>list1</li>
       <li>list2</li>
       <li>list3</li>
   </ul>
</div> 
Gunaseelan
  • 2,494
  • 5
  • 36
  • 43
user2962713
  • 15
  • 3
  • 6

7 Answers7

2

when you calling image using background-image please make sure to define the width and height property.

this is your CSS code and I added height and width

#flags {
position: relative;
background-image:url(http://lorempixel.com/200/200);
background-repeat: no-repeat;
background-position: bottom right;
float: left;
width:100%; //width:200px; /* added the width 100% is good for responsive */ 
height:auto; //height:200px; /* added the height For Responsive*/ 
}

Here is the working Demo. http://jsbin.com/lonarezu/1/edit

Gunaseelan
  • 2,494
  • 5
  • 36
  • 43
Kheema Pandey
  • 9,977
  • 4
  • 25
  • 26
1

try url in single quotes

.test{
    width:100%;
    height:415px;
    background-image:url('http://static.fkids.ru/photo/2011/07/2380/Diana-Pentovich5461568.jpg');
    background-repeat:no-repeat;
    }

WORKING DEMO

Sajad Karuthedath
  • 14,987
  • 4
  • 32
  • 49
0

try this

#flags {
position: relative;
background-image:url("example.png");
background-repeat: no-repeat;
background-position: bottom right;
float: right;
} 
Boopathi Rajan
  • 1,212
  • 15
  • 38
0

Try putting double quotes around image url like so

background-image:url("https://example.png");
user3352495
  • 374
  • 3
  • 11
  • 1
    Not necessary, unless there a special chars in the URL http://stackoverflow.com/questions/851724/css-background-image-what-is-the-correct-usage – mplungjan Mar 05 '14 at 05:34
0

The problem is you didn't set any dimensions for #flags div while your div element is floated. So you need to set either height and width of a #flag div or give a css property overflow:hidden to it's parent like given below. Then it will work perfectly fine.

Code:

<div style="overflow: hidden">

    <div id="flags">
        <p>text</p>
        <ul>
            <li>list1</li>
            <li>list2</li>
            <li>list3</li>
        </ul>
    </div>

</div>

Hopefully it will be your answer.

DEMO

Ahsan Khurshid
  • 9,383
  • 1
  • 33
  • 51
0

The problem is with your image address... It works when i put my own image in

    #flags {
    position: relative;
    background-image:url('http://th00.deviantart.net/fs71/PRE/i/2012/193/2/9/agua_png_by_eross_666-d56zr6u.png');
    background-repeat: no-repeat;
    background-position: bottom right;
    float: right;
    } 

http://jsfiddle.net/Kq48W/1/

Omar
  • 2,726
  • 2
  • 32
  • 65
0

I am sure that either your image path or extension is not correct. Check image extension and place the image in the same folder of html file.

Iqbal Kabir
  • 1,518
  • 10
  • 16