[英]How do I have images resize and retain the ability to have them change on hover
I have this issue.. I want to be able to use我有这个问题..我希望能够使用
.custom-forums {
height: auto;
width: 100%;
border-image-source:transparent url("../images/forums.png") center top no-
repeat;
}
with和
.custom-forums:hover {
background-image: url('../images/forums-hover.png');
}
The issue is this: When width
is set to 100%
it simply does not show the image.问题是:当
width
设置为100%
它根本不显示图像。 But when width
and height
are set to 170px
it does work.但是当
width
和height
设置为170px
它确实有效。 I would like to have the button resize based on screen resolution and retain the ability to have the hover image change.我希望根据屏幕分辨率调整按钮大小并保留更改悬停图像的能力。
Much gratitude, Mas21非常感谢, Mas21
Background images require a predefined height or content of a certain height in its container in order to work.背景图像需要在其容器中具有预定义的高度或特定高度的内容才能工作。
I had a thought you could do this another way:我有一个想法,你可以用另一种方式做到这一点:
Run this example:运行这个例子:
.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.