27 Mayıs 2010, PERŞEMBE
HTML / input type="düğme"?Resim Ekle simgesini Nasıl CSS
Aşağıda CSS kullanıyorum, ama bu düğmenin ortasındaki bir görüntü koyar. Ya da bir simge metni ve görüntüyü uygun <input type="button">
çok kullanarak soldan sağa Hizala ve güzel hizalamak için bir yolu var mı?
background: url('/common/assets/images/icons/16x16/add.png');
background-position:center;
background-repeat:no-repeat;
CEVAP
27 Mayıs 2010, PERŞEMBE
Bu ne istiyorsun, düğme resim 16 x 16 olduğunu varsayarsak.
<input type="button" value="Add a new row" class="button-add" />
input.button-add {
background-image: url(/images/buttons/add.png); /* 16px x 16px */
background-color: transparent; /* make the button transparent */
background-repeat: no-repeat; /* make the background image appear only once */
background-position: 0px 0px; /* equivalent to 'top left' */
border: none; /* assuming we don't want any borders */
cursor: pointer; /* make the cursor like hovering over an <a> element */
height: 16px; /* make this the size of your image */
padding-left: 16px; /* make text start to the right of the image */
vertical-align: middle; /* align the text vertically centered */
}
Örnek düğmesi:
Güncelleme
Eğer daha Az olursa, bu kendisine dahil ederse işe yarayabilir.
.icon-button(@icon-url, @icon-size: 16px, @icon-inset: 10px, @border-color: #000, @background-color: transparent) {
height: @icon-size * 2;
padding-left: @icon-size @icon-inset * 2;
padding-right: @icon-inset;
border: 1px solid @border-color;
background: @background-color url(@icon-url) no-repeat @icon-inset center;
cursor: pointer;
}
input.button-add {
.icon-button("http://placehold.it/16x16", @background-color: #ff9900);
}
Yukarıdaki derler
input.button-add {
height: 32px;
padding-left: 36px;
padding-right: 10px;
border: 1px solid #000000;
background: #ff9900 url("http://placehold.it/16x16") no-repeat 10px center;
cursor: pointer;
}
Bunu Paylaş:
Stil input type=&; dosya" düğme"...
Düğme metni değiştirmek için nasıl <...
Nasıl HTML5 input type=&; numara"...
Nasıl HTML 5 giriş type=&; tarih"...
İnput type=&; tarih" biçimini " d...