html - 悬停时缩放和居中图像

标签 html css twitter-bootstrap-3 transform

我正在为我的公司设计用户指南,需要找到一种更好的方式来查看图像。我已经在悬停时缩放以正常工作,但是只有当用户在查看图像时有一个大的计算机屏幕时,这才会正常工作。因此,我想将图像置于悬停中心。

此外,让图像根据窗口大小进行缩放会很不错。我有 Bootstrap 并且 jQuery 已链接。

我现在的代码

     .thumbnail {
        transition: transform .5s, left .5s; /* Animation */
    	margin: 0 auto;
        z-index: 2;
    }
    
       @media (min-width: 1600px) { 
       .thumbnail:hover {
    	transform: scale(1.75);
    
    }}
       
       @media (max-width: 1600px) { 
       .thumbnail:hover {
        transform: scale(1.5);
        position: relative;
        left: 25%;
    
    }}
    <img src="http://via.placeholder.com/350x150" class="thumbnail" style="width:800px; height:auto">
  

The big problem is the side menu who is part of the template on the business website. Click this link to see.

最佳答案

为 img 使用 object-fit 属性

.thumbnail {
 object-fit: cover;
}

关于html - 悬停时缩放和居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51496067/

相关文章:

javascript - 检测用户代理 Firefox

html - 如何在响应式 div 中调整模拟智能手机屏幕的大小?

html - 根据文本更改列表方向

javascript - 根据图像位置目录附加 CSS 样式

css-position - Bootstrap 3.0 : Fixed column

javascript - 当我的可滚动 div 达到一定高度时,如何使图像消失?

python - 使用python操作第三方网站的html源代码

javascript - 如何阻止链接更改页面上的位置(保持向后滚动位置)

html - 如何使 <details> 在鼠标悬停时下拉

javascript - 根据父级元素宽度而不是窗口 DOM 宽度触发响应