Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make background image of td to fit to 100% for non static images

I have td tag:

<td class="np-logo" style="width: 228px; height: 50px;">
                                            </td>

And CSS:

.np-logo
{
background-repeat: no-repeat;
background-size: 100%;
}

And i am changing the image according to company logo.and all images have different-different size and width.

.np-logo{background-image:url('" + companylogo + "');

The problem is images are not getting fitted to td correctly.i want them to occupy whole td .but for every company the background image position is non uniform.I even tried using java script on image load to fit to container. didn't worked though.

any help guys...?

like image 546
Milind Anantwar Avatar asked Mar 21 '13 08:03

Milind Anantwar


2 Answers

Try

background-size: 100% 100%;

where first value is for width and the second is for height.

You can know more about it by following this link

like image 174
Mr_Green Avatar answered Oct 10 '22 14:10

Mr_Green


Have you tried cover?

.np-logo {
    background-repeat: no-repeat;
    background-size: cover;
}
like image 45
Samuel Liew Avatar answered Oct 10 '22 12:10

Samuel Liew