0

I want some css to get the image within mentioned width and height without cropping.

I have done it like this :

.btnEdit{ background-image: url(/images/btn_Edit_PICO.gif); 
    cursor:pointer;
    margin: 0;
    padding: 0;
    border: 0;
    background-repeat: no-repeat;
    background-color: transparent;
    height: 22px ; 
    width: 54px;} 

But, it's not happening. Another button is there but with different size.

.btnDelete{background-image: url(/images/btn_Delete_PICO.gif); 
cursor:pointer; 
margin: 0;
padding: 0;
border: 0;
background-repeat: no-repeat;
background-color: transparent; 
height: 22px ;
width: 54px;}

I want those to be of same size although there actual image size may differ.

Image: Edit Delete Demo

Satinder singh
  • 10,100
  • 16
  • 60
  • 102
soham
  • 1,508
  • 6
  • 30
  • 47

3 Answers3

0

If you have to resize the background, I don't think it can be done. If your image has the right width and height use background-position to 'crop'.

0

why r u using two class? if your both button are same so use only one class

CSS

    .btn
    { 
    background:blue; 
    cursor:pointer; 
    margin: 0; 
    padding: 0;
    border: 0;
    background-repeat: no-repeat;
height: 22px ; 
width: 54px;
    } 

HTML

<div class="btn">
<input type="Button" value="EDIT"/>
</div>

<div class="btn">
<input type="Button" value="Delete"/>
</div>
Pawan Lakhara
  • 1,146
  • 4
  • 16
  • 28
  • There's image involved and also other concerns. That's why I used two different classes. Can it be solved? – soham Jan 17 '13 at 11:01
0

Have you tried using the CSS3 property background-size?

background-size: cover;

or

background-size: 100% auto;
estrar
  • 1,373
  • 4
  • 12
  • 37