CSS 事件悬停以获得更大的图片

标签 css

我尝试使用 bootstrap 和我的自定义 CSS 制作图片库。我想让如果用户将鼠标悬停在图像上,图片就会在其位置变大。一切都是通过仅使用 css 完成的,但我在图像网格方面遇到了一些问题。当我将鼠标悬停在最右边的图像时,位置会很困惑。这是我的实验:http://hanzoclothing.com/lookbook/chapter-iii

CSS:

.lookbook-item{
    position: relative !important;
}
.lookbook-item:hover{
    z-index: 5;
}
.lookbook-item .thumb{
    opacity: 1 !important;
}
.lookbook-item .thumb img{
    -webkit-transition: all 1s ease-in-out;
    transition: all 0.3s ease-in-out;
}
.lookbook-item .thumb:hover img{
    position: absolute;
    min-width: 600px;
    max-width: 600px;
    margin-top: -40px;
    margin-left: -50px;
/*    top: 200%;
    left: 23%;*/
    z-index: 6;
}

最佳答案

我很想使用 transform:scale(xxx); 为此。它将完全执行您想要的操作,而不会影响其他元素:

.lookbook-item .thumb:hover img {
    /* position: absolute; */
    /* min-width: 600px; */
    /* max-width: 600px; */
    /* margin-top: -40px; */
    /* margin-left: -50px; */
    z-index: 6;
    transform: scale(2);
}

如果您想保留当前的偏移量,可以使用以下内容:

变换:scale(2) 翻译(50px, 40px);

关于CSS 事件悬停以获得更大的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25361447/

相关文章:

javascript - 使用 Javascript 查找页面中的位置

html - 什么是 28"显示器的 CSS @media 查询?

css - 在响应表中插入边框

javascript - 在 Canvas 中心写(0,0)-HTML5

html - 为什么这些 HTML 表单按钮不能内联显示?

javascript - 下拉动画图标

html - CSS 背景 Outlook 2007

javascript - 具有 2 个级别的 jQuery 选项卡

jquery - .val() 无法按预期使用按钮。输入[类型=按钮]

javascript - Textarea 边界检查输入