0

I am designing an app in Unqork. The issue I have is how to shape the radio button to look like the regular Learn More button. I only intend to style the radio button instead of making it into a multiple choice.

The style of the regular button is

.abc-quote-option-cta {
    bottom: 38px;
    left: 0;
    right: 0;
    padding-top: 24px;
    position: absolute; }

.abc-quote-option-cta:before {
    background-color: #979797;
    content: '';
    display: block;
    height: 1px;
    left: 62px;
    opacity: .36;
    position: absolute;
    right: 56px;
    top: 0;
}

.abc-quote-option-cta .btn.btn-primary {
    border-radius: 6px;
    border: solid 2px #01a7e1;
    background-color: #FFFFFF;
    border-radius: 6px;
    color: #01a7e1;
    display: block;
    font-size: 1.8rem;
    line-height: 1.44;
    margin: 0 auto;
    padding: 10px;
    text-align: center;
    transition: background-color .25s ease, width .13s ease-in, color .18s ease-out ;
    width: 188px;
}

.abc-quote-option-cta .btn.btn-primary:hover,
.abc-quote-option-cta .btn.btn-primary:focus {
    background-color: #0099cc;
    color: #FFFFFF;
    width: 251px;
}

Your help is very much appreciated. Thanks!

IMSoP
  • 89,526
  • 13
  • 117
  • 169
Skipper Lin
  • 65
  • 1
  • 7
  • Does this answer your question? [How to style a checkbox using CSS](https://stackoverflow.com/questions/4148499/how-to-style-a-checkbox-using-css) – ino Aug 19 '20 at 14:33
  • Hi @djangotic, no really. It is for a checkbox, but I just hope to style the radio button exactly like the regular Learn More button. – Skipper Lin Aug 19 '20 at 14:37
  • If you're not using the radio to choose between multiple options ("... instead of making it into a multiple choice..."), why even use a radio at all? Why not opt to use a standard `button`, which would likely be significantly easier to style like this? – esqew Aug 19 '20 at 14:52
  • @esqew yeah I agree, but the things with regular button is that it cannot jump to another page. Once clicked the learn more button now, it only shows a success message. – Skipper Lin Aug 19 '20 at 15:12
  • @SkipperLin Can you elaborate on how you came to the conclusion that a "button... cannot jump to another page"? This is without a doubt achievable, a crude example being: `` – esqew Aug 19 '20 at 15:14
  • @esqew I understand it is easy to do so in normal html. However, I am using a no-code platform. – Skipper Lin Aug 19 '20 at 16:25
  • @SkipperLin! We have a private Stack Team for Unqork questions. Please post your question there for assistance and we will be glad to answer this for you! – Colton Oct 15 '20 at 17:40
  • Hey Skipper! Unqork has a private Stack Overflow team for the Unqork community so shoot me an email at colton@unqork.com and I'll give you access! – Colton Feb 10 '21 at 23:23

3 Answers3

3

I hope this snippet will help you.

form {
    max-width: 250px;
    position: relative;
    margin: 50px auto 0;
    font-size: 15px;
}
.radiobtn {
    position: relative;
    display: block;
}
.radiobtn label {
    display: block;
    background: rgba(0, 0, 0, 0.2);
    color: #000;
    border-radius: 5px;
    padding: 10px 20px;
    border: 2px solid grey;
    margin-bottom: 5px;
    cursor: pointer;
}
.radiobtn label:after, .radiobtn label:before {
    content: "";
    position: absolute;
    right: 11px;
    top: 11px;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    background:grey;
}
.radiobtn label:before {
    background: transparent;
    transition: 0.1s width cubic-bezier(0.075, 0.82, 0.165, 1) 0s, 0.3s height cubic-bezier(0.075, 0.82, 0.165, 2) 0.1s;
    z-index: 2;
    overflow: hidden;
    background-repeat: no-repeat;
    background-size: 13px;
    background-position: center;
    width: 0;
    height: 0;
    background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNS4zIDEzLjIiPiAgPHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE0LjcuOGwtLjQtLjRhMS43IDEuNyAwIDAgMC0yLjMuMUw1LjIgOC4yIDMgNi40YTEuNyAxLjcgMCAwIDAtMi4zLjFMLjQgN2ExLjcgMS43IDAgMCAwIC4xIDIuM2wzLjggMy41YTEuNyAxLjcgMCAwIDAgMi40LS4xTDE1IDMuMWExLjcgMS43IDAgMCAwLS4yLTIuM3oiIGRhdGEtbmFtZT0iUGZhZCA0Ii8+PC9zdmc+);
}
input[type="radio"] {
    display: none;
    position: absolute;
    width: 100%;
    appearance: none;
}
input[type="radio"]:checked + label {
    background:grey;
    animation-name: blink;
    animation-duration: 1s;
 border-color: $accentcolor;
}
input[type="radio"]:checked + label:after {
 background: $accentcolor;
}
input[type="radio"]:checked + label:before {
    width: 20px;
    height: 20px;
}
<form>
  <div class="radiobtn">
    <input type="radio" id="huey"
                     name="drone" value="huey" checked />
    <label for="huey">Learn More</label>
  </div>
  <div class="radiobtn">
    <input type="radio" id="dewey"
                     name="drone" value="dewey" />
    <label for="dewey">Learn More</label>
  </div>
</form>
Priya jain
  • 1,127
  • 2
  • 10
  • 22
  • Hi Priya, this is definitely helpful. Thank you so much. However, is there a way to make only one radio button? It is like a multiple choice with only the question but not the choices. – Skipper Lin Aug 19 '20 at 15:01
  • @SkipperLin If you want use one radio button. use only one radio button. What is the confusion in that? – Priya jain Aug 19 '20 at 15:07
  • sorry about that. I am not really familiar with CSS. One more question, is there a way to make the learn more radio button without the check mark? – Skipper Lin Aug 19 '20 at 15:16
  • Yes, If you want I can attach another snippet without check mark. – Priya jain Aug 19 '20 at 15:21
  • That could be great! Thank you so much. My goal is to make the radio button looks exactly the regular button. – Skipper Lin Aug 19 '20 at 15:33
  • I added another snippet without check mark. Please check I hope It will useful for you. Please accept my answer if it useful for you. – Priya jain Aug 19 '20 at 15:42
  • Thank you so much. I think it looks great. One more thing though: why after I use the scaling, the whole page looks out of scale. – Skipper Lin Aug 19 '20 at 16:14
  • Hey Skipper and Priya! Unqork have a private Stack Overflow team for the Unqork community so shoot me an email at colton@unqork.com and I'll give you access! – Colton Feb 10 '21 at 23:22
1

I hope this will help you.

form {
  max-width: 250px;
  position: relative;
  margin: 50px auto 0;
  font-size: 15px;
}

.radiobtn {
  position: relative;
  display: block;
}

.radiobtn label {
  display: block;
  background: rgba(0, 0, 0, 0.2);
  color: #000;
  border-radius: 5px;
  padding: 10px 20px;
  border: 2px solid grey;
  margin-bottom: 5px;
  cursor: pointer;
}

.radiobtn label:after,
.radiobtn label:before {
  content: "";
  position: absolute;
  right: 11px;
  top: 11px;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background: grey;
}

.radiobtn label:before {
  background: transparent;
  transition: 0.1s width cubic-bezier(0.075, 0.82, 0.165, 1) 0s, 0.3s height cubic-bezier(0.075, 0.82, 0.165, 2) 0.1s;
  z-index: 2;
  overflow: hidden;
  background-repeat: no-repeat;
  background-size: 13px;
  background-position: center;
  width: 0;
  height: 0;
  background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNS4zIDEzLjIiPiAgPHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE0LjcuOGwtLjQtLjRhMS43IDEuNyAwIDAgMC0yLjMuMUw1LjIgOC4yIDMgNi40YTEuNyAxLjcgMCAwIDAtMi4zLjFMLjQgN2ExLjcgMS43IDAgMCAwIC4xIDIuM2wzLjggMy41YTEuNyAxLjcgMCAwIDAgMi40LS4xTDE1IDMuMWExLjcgMS43IDAgMCAwLS4yLTIuM3oiIGRhdGEtbmFtZT0iUGZhZCA0Ii8+PC9zdmc+);
}

input[type="radio"] {
  display: none;
  position: absolute;
  width: 100%;
  appearance: none;
}

input[type="radio"]:checked+label {
  background: grey;
  animation-name: blink;
  animation-duration: 1s;
  border-color: $accentcolor;
}

input[type="radio"]:checked+label:after {
  background: $accentcolor;
}

input[type="radio"]:checked+label:before {
  width: 20px;
  height: 20px;
}
<form>
  <div class="radiobtn">
    <input type="radio" id="huey" name="drone" value="huey" checked />
    <label for="huey">Learn More</label>
  </div>
  <div class="radiobtn">
    <input type="radio" id="dewey" name="drone" value="dewey" />
    <label for="dewey">Learn More</label>
  </div>
</form>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Priya jain
  • 1,127
  • 2
  • 10
  • 22
1

Custom radio button without check mark.

form {
    max-width: 200px;
    position: relative;
    margin: 50px auto 0;
    font-size: 15px;
}
.radiobtn {
    position: relative;
    display: block;
    text-align:center;
}
.radiobtn label {
    display: block;
    background:none;
    color:#01a7e1;
    border-radius: 5px;
    padding: 10px 20px;
    border: 2px solid #01a7e1;
    margin-bottom: 5px;
    cursor: pointer;
    font-family:Arial, Helvetica, sans-serif;
}
input[type="radio"] {
    display: none;
    position: absolute;
    width: 100%;
    appearance: none;
}
input[type="radio"]:checked + label {
    background:#01a7e1;
    color:#fff;
}
<form>
  <div class="radiobtn">
    <input type="radio" id="huey"
                     name="drone" value="huey" checked />
    <label for="huey">Learn More</label>
  </div>
  <div class="radiobtn">
    <input type="radio" id="dewey"
                     name="drone" value="dewey" />
    <label for="dewey">Learn More</label>
  </div>
</form>
Priya jain
  • 1,127
  • 2
  • 10
  • 22