gpt4 book ai didi

html - 背景图像过渡不适用于表单按钮

转载 作者:行者123 更新时间:2023-11-28 12:22:07 24 4
gpt4 key购买 nike

我有一个像这样的简单表格:

<section class="subscribe" title='Lorem Ipsum'>
<form class="form-wrapper cf" method="post">
<input class="tiptipNewsletterInfo" id="emailInputText" name="email" placeholder="Enter your email here..." />
<button class="showforDesktopsOnly" id="submitBtnForDesktop" type="submit">Subscribe</button>
</form>
</section>

现在,我想更改鼠标悬停在提交按钮上时显示的背景图像。为此,我尝试使用以下 CSS,但它不起作用:

.form-wrapper #submitBtnForDesktop {
background: url("http://i.imgur.com/ANkUR4e.png") no-repeat 0 0 transparent;
transition: background-image 0.5s;
}

.form-wrapper #submitBtnForDesktop:hover {
background: url("http://i.imgur.com/ANkUR4e.png") no-repeat 0 -28px transparent;
}

我目前在其他地方使用 transition: background-image 0.5s; 来更改鼠标悬停时的其他背景图像,但在这种情况下它不起作用。

有人知道为什么吗?

JSFiddle:http://jsfiddle.net/ahmadka/49nzM/

最佳答案

css3 转换仅适用于数字和(在某些浏览器中)颜色十六进制值,但不适用于您尝试做的图像背景

要实现您想要的“从一个图像淡入到另一个图像”,您需要更改 html&css;

html

....
<button class="showforDesktopsOnly" id="submitBtnForDesktop" type="submit">
<div class="hax"></div>
Subscribe
</button>
....

CSS

....
#submitBtnForDesktop .hax{
width:100%;
height:100%;
background: url("http://i.imgur.com/ANkUR4e.png") no-repeat 0 0 transparent;
transition: opacity 0.5s;
opacity:1
}
#submitBtnForDesktop:hover .hax{
opacity:0
}
....

关于html - 背景图像过渡不适用于表单按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18806204/

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