gpt4 book ai didi

html - 悬停时 CSS3 阴影变暗

转载 作者:行者123 更新时间:2023-11-28 00:04:50 24 4
gpt4 key购买 nike

我在图像上添加了阴影叠加层,但我希望在悬停图像时阴影变暗。我尝试了很多不同的东西,但我无法让它正常工作,当你悬停时它会把图片到处移动。这是我目前所拥有的。

http://jsfiddle.net/Qf4Ka/6/

HTML

<section id="top-container" class="top-column" style="width:1050px; height:400px; ">
<div class="image" style="float:left;">
<img src="http://www.hdwallpapersinn.com/wp-content/uploads/2012/09/HD-Wallpaper-1920x1080.jpg" border="0"; width="263"; height="200" style="display: block; border-top: 1px solid #dddddd; border-bottom: 1px solid #dddddd; border-right: 1px solid #dddddd;">
<h4 style="font-size:30px; top: 90px; ">Nature</h4>
</div>
<div class="image" style="float:left;">
<img src="http://www.hdwallpapersart.com/wp-content/uploads/2013/04/tiger_wallpapers_hd_Bengal_Tiger_hd_wallpaper1.jpg" border="0"; width="262"; height="200" style="display: block; border-top: 1px solid #dddddd; border-bottom: 1px solid #dddddd; ">
<h4 style="font-size:30px; top: 90px;">Bengal Tiger</h4>
</div>
</section>

CSS

.image {
position: relative;
}

h4 {
position: absolute;
width: 100%;
color: #fff;
float: left;
position: absolute;
font-size: 40px;
font-family: "Oswald";
text-align: center;
max-height: auto;
z-index: 20;
text-shadow: 1px 1px 2px #000;
-moz-text-shadow: 1px 1px 2px #000;
-ms-text-shadow: 1px 1px 2px #000;
-o-text-shadow: 1px 1px 2px #000;
-webkit-text-shadow: 1px 1px 2px #000;
}

.image {
position: relative;
}

.image:before {
content: '';
box-shadow: 0 0 50px 4px #000 inset;
-moz-box-shadow: 0 0 50px 4px #000 inset;
-webkit-box-shadow: 0 0 50px 6px #000 inset;
float: left;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 20;
cursor: pointer;
}

最佳答案

:before 伪元素添加一个 transition

.image:before {
transition: all 1s;
-webkit-transition: all 1s;
-moz-transition:all 1s;
}

.image 元素的 hover 上更改伪元素的 box-shadow

.image:hover:before {
box-shadow:0 0 100px 30px #000 inset;
}

这是 updated example .

关于html - 悬停时 CSS3 阴影变暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19074889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com