gpt4 book ai didi

html - 修复 html 和 css 代码

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

我想知道,为什么我可以选择两张图片而不是一张。 (是一个图像而不是单选按钮)。例如,如果您尝试选择 2 张图片,这些图片看起来已被选中,但我希望可以只选择其中一张。

查看jsFiddle或查看下面的代码段:

* {
margin: 0;
padding: 0;
}
.main {
position: relative;
z-index: 10;
padding-top: 60px;
color: #999;
width: 100%;
min-height: calc(100vh - 60px);
}
.wrap{position:relative}
.wrap{width:100%;margin:0 auto;max-width:1024px;padding:0 16px}
.write {
position: relative;
max-width: 690px;
padding: 40px 16px 70px;
}
.write-gender{
text-align: center;
}
.write-gender {
display: inline-block;
width: 128px;
height: 128px;
margin: 0 10px;
border: 5px solid transparent;
border-radius: 100%;
}
.form__label, h6 {
font-weight: 500;
font-size: 14px;
text-transform: uppercase;
}
.form__label, h4, h6 {
line-height: 1.2em;
margin-bottom: 20px;
}
h6 {
display: block;
font-size: 0.67em;
-webkit-margin-before: 2.33em;
-webkit-margin-after: 2.33em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
font-weight: bold;
}
.write-title {
text-align: center;
margin-top: 18px;
font-size: 13px;
margin-bottom: 60px;
position: relative;
left: 235px;
}
.gender-selector input{
-webkit-appearance:none;
-moz-appearance:button;
appearance:button;
margin:0;
padding:0;
}
.man{
background-image:url(https://cdn1.iconfinder.com/data/icons/user-pictures/100/male3-512.png);
border-color: #1f6ab0;
position: relative;
left: 400px;
bottom: 80px;
display: block;
max-width: 100%;
}

.gender-selector:not(input:checked) input:active +.gen-sel{
opacity: .6;
}

.gender-selector input:checked +.gen-sel{
-webkit-filter: none;
-moz-filter: none;
filter: none;
}

.women{
background-image:url(https://cdn1.iconfinder.com/data/icons/user-pictures/100/female1-512.png);
border-color: #b24592;
position: relative;
left: 60px;
top: 3px;
display: block;
max-width: 100%;
}

.gen-sel{
cursor:pointer;
display:inline-block;
width:100px;
height:70px;
background-size:contain;
background-repeat:no-repeat;
-webkit-filter: brightness(1.8) grayscale(1) opacity(.7);
-moz-filter: brightness(1.8) grayscale(1) opacity(.7);
filter: brightness(1.8) grayscale(1) opacity(.7);
}
.gen-sel:hover{
-webkit-filter: brightness(1.2) grayscale(.5) opacity(.9);
-moz-filter: brightness(1.2) grayscale(.5) opacity(.9);
filter: brightness(1.2) grayscale(.5) opacity(.9);
}
<main class="main ">
<div>
<div class="wrap write">
<div class="write-gender">
<h6 class="write-title">Select gender</h6>
<div class="gender-selector">
<input id="gender" type="radio" name="gender" value="w" />
<label class="gen-sel write-gender women" for="gender"></label>
<input id="gender2" type="radio" name="gender2" value="m" />
<label class="gen-sel write-gender man"for="gender2"></label>
</div>
</div>
</div>
</div>
</main>

我还想知道其他事情:- 我已经创建了一个数据库来存储这些信息。 id 是“性别”,在输入的 html 代码中,我在我的 PHP 代码中用 id --> gender 调用了一个输入,用 id --> gender2 调用了另一个输入,我将 id gender2 与 id gender 相匹配通过使用这个 --> "$gender2 =& $gender; "是对的吗?

最佳答案

如果您使用单选按钮,请使用相同的 name 属性 - gender,例如:

<div class="gender-selector">
<input id="gender" type="radio" name="gender" value="w" />
<label class="gen-sel write-gender women" for="gender"></label>
<input id="gender2" type="radio" name="gender" value="m" />
<label class="gen-sel write-gender man"for="gender2"></label>
</div>

看看下面的代码片段,或更新的 fiddle .

* {
margin: 0;
padding: 0;
}
.main {
position: relative;
z-index: 10;
padding-top: 60px;
color: #999;
width: 100%;
min-height: calc(100vh - 60px);
}
.wrap{position:relative}
.wrap{width:100%;margin:0 auto;max-width:1024px;padding:0 16px}
.write {
position: relative;
max-width: 690px;
padding: 40px 16px 70px;
}
.write-gender{
text-align: center;
}
.write-gender {
display: inline-block;
width: 128px;
height: 128px;
margin: 0 10px;
border: 5px solid transparent;
border-radius: 100%;
}
.form__label, h6 {
font-weight: 500;
font-size: 14px;
text-transform: uppercase;
}
.form__label, h4, h6 {
line-height: 1.2em;
margin-bottom: 20px;
}
h6 {
display: block;
font-size: 0.67em;
-webkit-margin-before: 2.33em;
-webkit-margin-after: 2.33em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
font-weight: bold;
}
.write-title {
text-align: center;
margin-top: 18px;
font-size: 13px;
margin-bottom: 60px;
position: relative;
left: 235px;
}
.gender-selector input{
-webkit-appearance:none;
-moz-appearance:button;
appearance:button;
margin:0;
padding:0;
}
.man{
background-image:url(https://cdn1.iconfinder.com/data/icons/user-pictures/100/male3-512.png);
border-color: #1f6ab0;
position: relative;
left: 400px;
bottom: 80px;
display: block;
max-width: 100%;
}

.gender-selector:not(input:checked) input:active +.gen-sel{
opacity: .6;
}

.gender-selector input:checked +.gen-sel{
-webkit-filter: none;
-moz-filter: none;
filter: none;
}

.women{
background-image:url(https://cdn1.iconfinder.com/data/icons/user-pictures/100/female1-512.png);
border-color: #b24592;
position: relative;
left: 60px;
top: 3px;
display: block;
max-width: 100%;
}

.gen-sel{
cursor:pointer;
display:inline-block;
width:100px;
height:70px;
background-size:contain;
background-repeat:no-repeat;
-webkit-filter: brightness(1.8) grayscale(1) opacity(.7);
-moz-filter: brightness(1.8) grayscale(1) opacity(.7);
filter: brightness(1.8) grayscale(1) opacity(.7);
}
.gen-sel:hover{
-webkit-filter: brightness(1.2) grayscale(.5) opacity(.9);
-moz-filter: brightness(1.2) grayscale(.5) opacity(.9);
filter: brightness(1.2) grayscale(.5) opacity(.9);
}
<main class="main ">
<div>
<div class="wrap write">
<div class="write-gender">
<h6 class="write-title">Select gender</h6>
<div class="gender-selector">
<input id="gender" type="radio" name="gender" value="w" />
<label class="gen-sel write-gender women" for="gender"></label>
<input id="gender2" type="radio" name="gender" value="m" />
<label class="gen-sel write-gender man"for="gender2"></label>
</div>
</div>
</div>
</div>
</main>

希望这对您有所帮助!

关于html - 修复 html 和 css 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41168867/

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