Show background image on td tag

I am trying to show a background image on a td tag. and i have a code

<td style="background-image:url(../uploadimages/18-2-2013-23-33-01-Lighthouse.jpg);background-repeat:no-repeat;background-size:250px 180px;"></td> <img src="../uploadimages/18-2-2013-23-33-01-Lighthouse.jpg" /> 

I am testing the path using the img tag and it gets the correct path, but I do not know that it does not appear in the background image on the td tag.

Many thanks

+7
source share
2 answers

td will not display a background image because it has no content, so td no place to draw a background. background-size sets the background size, not the size of the container. Try width:250px;height:180px; in the inline style for td - it should show the image.

Here's a demo in jsfiddle . If you remove the width and height settings from the CSS, you will not see the image.

+8
source

The right decision

First of all, you must specify the width and height td. Follow an example that will work correctly.

 <td style="background-image:url(../uploadimages/18-2-2013-23-33-01-Lighthouse.jpg);background-repeat:no-repeat;background-size:250px 180px; width: 250px; height: 180px;"></td> 
+2
source

All Articles