In the snippet below I have simulated a donation widget however when the user enters text into the input type="text"
I want the checked radio to lose its checked state. Is there a CSS solution or will this require a jQuery function?
*,
*::before,
*::after {
box-sizing: border-box;
}
::-webkit-input-placeholder {
color: #b6b6b6;
}
:-moz-placeholder {
color: #b6b6b6;
opacity: 1;
}
::-moz-placeholder {
color: #b6b6b6;
opacity: 1;
}
:-ms-input-placeholder {
color: #b6b6b6;
}
::-ms-input-placeholder {
color: #b6b6b6;
}
::placeholder {
color: #b6b6b6;
}
body {
background: #fff;
width: 100%;
margin: auto;
padding: 30px;
min-width: 320px;
max-width: 540px;
border-radius: 3px;
}
.inline-radio {
font-size: 19px;
display: -webkit-box;
display: flex;
border-radius: 3px;
}
.inline-radio div {
border: 1px solid #ededed;
margin-top: -1px;
margin-left: -1px;
position: relative;
-webkit-box-flex: 1;
flex: 1;
}
.inline-radio div:last-child {
color: #b6b6b6;
padding: 0 0.9rem;
display: flex;
align-items: center;
}
.inline-radio input[type="radio"] {
cursor: pointer;
width: 100%;
height: 60px;
opacity: 0;
}
.inline-radio input[type="text"] {
font-size: inherit;
color: #b6b6b6;
margin-left: 0.3rem;
display: flex;
border: none;
outline: none;
}
.inline-radio label {
position: absolute;
top: 0;
left: 0;
color: #b6b6b6;
width: 100%;
height: 100%;
background: #fff;
display: -webkit-box;
display: flex;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: center;
justify-content: center;
pointer-events: none;
}
.inline-radio input:checked+label {
background: #d81b60;
font-weight: 500;
color: #fff;
}
<div class="inline-radio">
<div><input type="radio" name="title"><label>$5</label></div>
<div><input type="radio" name="title" checked><label>$25</label></div>
<div><input type="radio" name="title"><label>$50</label></div>
<div><input type="radio" name="title"><label>$100</label></div>
<div><span>$</span><input type="text" placeholder="Other Amount"></div>
</div>