[英]Keep background when button is hidden? (CSS/Javascript)
I got a form with checkboxes. 我有一个带有复选框的表格。 The Submit button first is hidden.
首先“提交”按钮被隐藏。 When i check one checkbox at least the button will appear.
当我选中一个复选框时,至少会出现该按钮。 That is working.
可以了 But the button has some background image and that will also only appear when the button is visible.
但是按钮具有一些背景图像,并且仅在按钮可见时才会显示。 I want the background image to be always there.
我希望背景图片始终存在。 Is there a way to to this?
有没有办法做到这一点?
HTML : HTML:
<div class="wrapper2"><input type = button class="next_button" name="commit" value="Submit" onClick="resultFunction();" >
CSS : CSS:
.wrapper2{
margin-top: 230px;
text-align: center;
background: -moz-linear-gradient(left, rgba(89,106,114,1) 0%, rgba(206,220,231,1) 58%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(89,106,114,1)), color-stop(58%,rgba(206,220,231,1)));
}
i forgot to add this here: 我忘了在这里添加:
$(".next_button").hide();
$("#question1, #question2, #question3, #question4").change(function () {
if ($("#question1").is(':checked') ||
$("#question2").is(':checked') ||
$("#question3").is(':checked') ||
$("#question4").is(':checked')
) {
$(".next_button").show();
}
});
您需要将按钮放在容器中,并为该容器提供背景,并确保容器具有宽度和高度,然后隐藏并仅显示按钮将容器背景保留在那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.