css - 调整 "ul hover"上的图片大小

标签 css animation hover html-lists

我最近遇到了 CSS 的一个小问题。我对列表进行了一些设计,现在想要悬停效果。因此,当您将鼠标悬停在列表项上时,其中的图像会调整大小,而其余部分(文本 - 跨度)保持不变。

<ul id="Somename">
    <li>
    <a id="ID1" href="LINK">
        <img alt="Something 1" src="LINK">
        <span>Text</span>
    </a>
</li>
<li>
    <a id="ID2" href="LINK">
        <img alt="Something 2" src="LINK">
        <span>Text</span>
    </a>
</li>
<li>
    <a id="ID3" href="LINK">
        <img alt="Something 3" src="LINK">
        <span>Text</span>
    </a>
</li>

我试着像完成动画一样制作动画here , 但无法做到。

我试过的方法是

#Somename a:hover > img {width: XXpx; }

最佳答案

这是一个简单的示例,可以帮助您开始设置 html 样式。这将像示例中那样放大并旋转图像:

JS Fiddle

/* Give the parent li item a relative position. Hide overflowed content since image will overflow*/
li {
    width: 300px;
    height: 300px;
    margin: 10px;
    overflow: hidden;
    background: black;
    color: white;
    position: relative;
}
li span {
    color: white;
    position: absolute;
    z-index: 999;
}
/* Set an initial size and rotate to be transitioned */
#Somename a > img {
    width: 200px;
    transition: .4s;
    position: absolute;
    transform: rotate(0deg);
}
/* Add hover styles to scale and rotate */
#Somename li:hover a > img {
    width: 300px;
    transform: rotate(90deg);
}

关于css - 调整 "ul hover"上的图片大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32592022/

相关文章:

jquery - 使用 jQuery 获取 html 元素渲染高度

css - 如何在标题模块中居中全宽背景图像?

animation - 将多个 Postscript 图像转换为动画 gif

ios - Cocos2d v3.0 - 使用带动画的物理编辑器

html - 按钮的绝对定位实现响应式

html - float 内的 z-index 不会溢出到兄弟节点

javascript - 当浏览器下载所需文件时,GIF 在启动画面中缓慢动画

html - 如何为图像标签制作悬停

html - 大型菜单 div 不会悬停在 Internet Explorer 上嵌入的 YouTube 上

html - 在 css 中集成悬停的正确方法