Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Bootstrap 3鼠标悬停图像响应_Jquery_Image_Css_Twitter Bootstrap_Twitter Bootstrap 3 - Fatal编程技术网

Jquery Bootstrap 3鼠标悬停图像响应

Jquery Bootstrap 3鼠标悬停图像响应,jquery,image,css,twitter-bootstrap,twitter-bootstrap-3,Jquery,Image,Css,Twitter Bootstrap,Twitter Bootstrap 3,是否有针对Bootstrap 3的响应式图像鼠标盖的解决方案 这是我的密码: 谢谢大家! 它需要更多的HTML代码,但您可以使用与之相同的基本技术。您需要在某个地方设置宽度(因为背景图像没有固有的尺寸),但这可能来自父元素。基本上: <div class="wrapper-with-intrinsic-ratio"><div class="element-to-stretch"></div></div> .wrapper-with-intrins

是否有针对Bootstrap 3的响应式图像鼠标盖的解决方案

这是我的密码:


谢谢大家!

它需要更多的HTML代码,但您可以使用与之相同的基本技术。您需要在某个地方设置宽度(因为背景图像没有固有的尺寸),但这可能来自父元素。基本上:

<div class="wrapper-with-intrinsic-ratio"><div class="element-to-stretch"></div></div>

.wrapper-with-intrinsic-ratio {
    position: relative;
    padding-bottom: 20%; /* Adjust this to suit the aspect ratio of the image */
    height: 0;
    width: 100%;
}
.element-to-stretch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("http://placehold.it/350x150/000/fff");
    background-size: cover;
}
.element-to-stretch:hover {
    background-image: url("http://placehold.it/350x150/ccc/fff");
}

或者您可以使用javascript。

它需要更多的HTML代码,但您可以使用与javascript相同的基本技术。您需要在某个地方设置宽度(因为背景图像没有固有的尺寸),但这可能来自父元素。基本上:

<div class="wrapper-with-intrinsic-ratio"><div class="element-to-stretch"></div></div>

.wrapper-with-intrinsic-ratio {
    position: relative;
    padding-bottom: 20%; /* Adjust this to suit the aspect ratio of the image */
    height: 0;
    width: 100%;
}
.element-to-stretch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("http://placehold.it/350x150/000/fff");
    background-size: cover;
}
.element-to-stretch:hover {
    background-image: url("http://placehold.it/350x150/ccc/fff");
}

或者你可以使用javascript。

或者你可以只使用一个简单的onmouseover html标记&给它一个从bootstrap响应的img类

.img响应,
.thumbnail>img,
.a>img,
.carousel-inner>.item>img,
.carousel-inner>.item>a>img{
显示:块;
最大宽度:100%;
高度:自动;
}

或者您可以只使用一个简单的onmouseover html标记&给它一个从bootstrap响应的img类

.img响应,
.thumbnail>img,
.a>img,
.carousel-inner>.item>img,
.carousel-inner>.item>a>img{
显示:块;
最大宽度:100%;
高度:自动;
}


您能解释更多吗?我不明白。我希望在手机上有像这样的快速响应的鼠标图像,我可以触摸图像,我可以看到鼠标在图像上。问题是,由于div需要宽度和高度,所以没有响应。你能解释更多吗?我不明白。我希望在手机上有像这样的快速响应的鼠标图像,我可以触摸图像,我可以看到鼠标在图像上。问题是–没有响应,因为div需要宽度和高度。没有问题。两件事:这是我的。其次,纵横比可能很棘手:如果纵横比为2:1(因此图像的宽度是其高度的两倍),则
上的
填充底部
。用(高度÷宽度)×100计算。因此,对于350×150px的图像,它应该是
填充底部:42.857%对于150x350px,它是
233.333%
。我会把这个编辑成答案,没问题。两件事:这是我的。其次,纵横比可能很棘手:如果纵横比为2:1(因此图像的宽度是其高度的两倍),则
上的
填充底部
。用(高度÷宽度)×100计算。因此,对于350×150px的图像,它应该是
填充底部:42.857%对于150x350px,它是
233.333%
。我将把这个编辑成答案。
<div>
    <img src="normal.jpg" alt="" class="normal"><img src="hover.jpg" alt="" class="hover">
</div>

div img { max-width: 100%; height: auto; }
div img.normal,
div:hover img.hover { display: block; }
div img.hover,
div:hover img.normal { display: none; }