gpt4 book ai didi

html - 图像复选框不工作

转载 作者:行者123 更新时间:2023-11-27 23:21:15 25 4
gpt4 key购买 nike

我有 3 个图片复选框。使用此代码:Codepen 1它们看起来像我想要的。

在下一步中,我添加了表单:Codepen 2

现在您看到了 - 表单正在创建 3 个自己的复选框而不是使用图片。你能帮帮我吗?

最佳答案

更改您的 <option>id<label>for属性(在你的情况下使用 cb1cb2 & cb3<option>id 属性),就像:

<li>
<input type="checkbox" id="cb1" value="1" />
<label for="cb1"><img src="http://betailor.de/wp-content/uploads/2016/12/engern.png" /></label>
</li>

看看下面的工作片段:

ul {
list-style-type: none;
}

li {
display: inline-block;
}

input[type="checkbox"][id^="cb"] {
display: none;
}

label {
border: 1px solid #fff;
padding: 10px;
display: block;
position: relative;
margin: 10px;
cursor: pointer;
}

label:before {
background-color: white;
color: white;
content: " ";
display: block;
border-radius: 50%;
border: 1px solid grey;
position: absolute;
top: -5px;
left: -5px;
width: 25px;
height: 25px;
text-align: center;
line-height: 28px;
transition-duration: 0.4s;
transform: scale(0);
}

label img {
height: 49px;
width: 122px;
transition-duration: 0.2s;
transform-origin: 50% 50%;
}

:checked + label {
border-color: #ddd;
}

:checked + label:before {
content: "✓";
background-color: green;
transform: scale(1);
}

:checked + label img {
transform: scale(0.9);
box-shadow: 0 0 5px #333;
z-index: -1;
}
<form method="post" action="processform.php">
<ul>
<li><input type="checkbox" id="cb1" value="1" />
<label for="cb1"><img src="http://betailor.de/wp-content/uploads/2016/12/engern.png" /></label>
</li>
<li><input type="checkbox" id="cb2" value="1" />
<label for="cb2"><img src="http://betailor.de/wp-content/uploads/2016/12/Kürzen.png" /></label>
</li>
<li><input type="checkbox" id="cb3" value="1" />
<label for="cb3"><img src="http://betailor.de/wp-content/uploads/2016/12/reapieren.png" /></label>
</li>
</ul>
<input type="submit" name="send" value="Submit" />
</p>
</form>

希望这对您有所帮助!

关于html - 图像复选框不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40944525/

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