我如何才能使当我选择的选项,具有值1(万事达卡)的图像与id主更改不透明度为1?并把它放在一个功能,适用于两个4值,每个上与他自己的id?默认的图像,我希望它是0. 3,当选择的选项之一的图像具有不透明度1。
.itemForm2 {
width: 100%;
position: relative;
margin-bottom: 18px;
margin-top: 10px;
display: flex;
flex-direction: row;
}
.escolhaCartao {
display: flex;
flex-direction: row;
width: 218px!important;
gap: 10px;
}
@media(min-width:768px) {
.escolhaCartao {
width: 258px!important;
height: 34.32px;
gap: 5px;
}
.lineFormCartao {
display: flex;
flex-direction: row;
justify-content: inherit;
gap: 16px;
}
.escolhaCartao img {
opacity: .3;
}
}
<div class="lineForm lineFormCartao">
<div class="itemForm">
<select id="OpcoesCartao" name="OpcoesCartao">
<option value="1">Mastercard</option>
<option value="2">Visa</option>
<option value="3">Elo</option>
<option value="4">Amex</option>
</select>
</div>
<div class="itemForm2 escolhaCartao">
<img id="master" src="images/master.png" alt="Logo cartão Mastercard">
<img id="visa" src="images/visa.png" alt="Logo cartão Visa">
<img id="elo" src="images/elo.png" alt="Logo cartão Elo">
<img id="amex" src="images/amex.png" alt="Logo cartão Amex">
</div>
</div>
2条答案
按热度按时间4ioopgfo1#
你可以像这样做。这在大多数浏览器中都可以工作。Firefox应该很快就会支持它(https://caniuse.com/?search=has)
vxbzzdmp2#
只使用CSS和has
使用JavaScript