![](/img/trans.png)
[英]How do I replace a form button with an image, and have the image change on hover? Also sprites vs separate images?
[英]How do I have images resize and retain the ability to have them change on hover
我有這個問題..我希望能夠使用
.custom-forums {
height: auto;
width: 100%;
border-image-source:transparent url("../images/forums.png") center top no-
repeat;
}
和
.custom-forums:hover {
background-image: url('../images/forums-hover.png');
}
問題是:當width
設置為100%
它根本不顯示圖像。 但是當width
和height
設置為170px
它確實有效。 我希望根據屏幕分辨率調整按鈕大小並保留更改懸停圖像的能力。
非常感謝, Mas21
背景圖像需要在其容器中具有預定義的高度或特定高度的內容才能工作。
我有一個想法,你可以用另一種方式做到這一點:
運行這個例子:
.container { background: url('http://placehold.it/199x199') no-repeat center center; width: 200px; } img { transition: opacity ease-in-out .5s; } img:hover { opacity: .25; }
<div class="container"> <img src="http://placehold.it/200x200"> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.