javascript - 在移动 View 中悬停图像大小

标签 javascript jquery html css responsive-design

我有个人资料图片缩略图,悬停时可以看到更大的图片,它出现在 span 中.. 它在大屏幕浏览器中完美运行,但在移动 View 中悬停时显示相同尺寸的大图..

https://jsfiddle.net/5L88ww69/

HTML:

   <a href="#" class="thumbnail2"> 
                          <img src="img/user/04.jpg" width="60" height="60" class="img-thumbnail"/>
                          <span style="top:60px; left: 60px; width: 400px;height: 450px;"><img src="img/user/04.jpg" class="img-thumbnail"/><br /></span>
                        </a>

CSS:

  .thumbnail2  {
  position: relative;
   float: left;
   z-index: 50;
  }

 .thumbnail2:hover span {
  visibility: hidden;
 }

.thumbnail2 span { 
  position: absolute;
  padding: 5px;
  visibility: hidden;
 text-decoration: none;
 }

.thumbnail2 span img { 
 border-width: 0px; 
 }


.thumbnail2:hover span { 
  visibility: visible; 
  width: 800px;
  height: 800px;
  top: 60px; 
  left: 60px;
 }

如何在移动 View 中显示完全适合移动 View 的大图?

最佳答案

使用媒体查询

 @media all and (max-width: 600px){
   .thumbnail2 span {
    left: 0!important;
    width: 100%!important;
    overflow: hidden;
}
.thumbnail2 span img {
    width: 100%!important;
}
 }

jsFiddle

关于javascript - 在移动 View 中悬停图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36448707/

相关文章:

javascript - 无法将 websocket 连接到 service-worker

javascript - 如果子 div 具有特定值,则删除父 div 类

javascript - jQuery获取容器的html,包括容器本身

jQuery 在 $(html_with_inline_styles) 上丢失样式

javascript - 这两行 jQuery 等效吗?

html - CSS 实现类似的固定 float div,它总是位于其他 div 之上——就像 stackoverflow 一样?

javascript - contentEditable div 中的粗体选定文本,使用纯 JavaScript,不使用 jQuery 等库

javascript - 如何在父div中水平居中多个div

html - 如何用三 Angular 形做一个透明的泡泡聊天?

html - Safari 中的页面呈现方式不同 - 所有其他浏览器都正常