gpt4 book ai didi

html - CSS:悬停时更改div中的图像

转载 作者:太空宇宙 更新时间:2023-11-04 02:17:06 26 4
gpt4 key购买 nike

目标:构建两个 block ,它们应该在悬停时改变它们的背景颜色、文本颜色和图标。

问题:我对背景和文字没有问题,但我发现图标有些困难。如何编辑我的 HTML 或 CSS 以达到目标?

这是我的代码:https://jsfiddle.net/teyrq0ze/悬停时应使用的图像:http://i.imgur.com/8MqehqH.png, http://i.imgur.com/pNgIqxQ.png .

最佳答案

在鼠标悬停在 div 上时向图像添加 filter

body {
margin: 0;
padding: 0;
width: 100%;
color: #333;
font-family: 'Open Sans', sans-serif;
font-size: 15px;
background: #333;
}

#footerblurb {
color: #fff;
}

#footerblurb-inner {
margin: 0 auto;
width: 650px;
}

#footerblurb .column1,
.column2 {
float: left;
display: table;
width: 290px;
padding: 15px;
cursor: pointer;
border: 1px dashed #fff;
transition: all .1s ease-in-out;
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
}

#footerblurb .column1 {
margin-right: 6px;
}

#footerblurb .column1:hover,
.column2:hover {
color: #333;
background: #fff;
}

#footerblurb .column1 img {
float: left;
vertical-align: middle;
display: table-cell;
}

#footerblurb .column2 img {
float: right;
vertical-align: middle;
display: table-cell;
}

#footerblurb .column1 span {
text-align: center;
vertical-align: middle;
display: table-cell;
}

#footerblurb .column2 span {
text-align: center;
vertical-align: middle;
display: table-cell;
}
#footerblurb .column1:hover img,
#footerblurb .column2:hover img{
-webkit-filter: invert(100%);
filter: invert(100%);
}
<div id="footerblurb">
<div id="footerblurb-inner">

<div class="column1" onclick="location.href=''">
<span><img class="previous" src="http://i.imgur.com/0tnecTN.png"></span>
<span>text text text</span>
</div>
<div class="column2" onclick="location.href=''">
<span>text text text</span>
<span><img class="next" src="http://i.imgur.com/e86z3mD.png"></span>
</div>

<div class="clr"></div>
</div>
</div>

已更新 Demo这里

你可以使用不同的过滤来赋予不同的颜色。

更多信息read this

关于html - CSS:悬停时更改div中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38737313/

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