Answer №1

Here is an example of HTML and CSS code:

<div class="radio-button">
    <input class="radio-button__input" type="radio" name="" id="btn">
    <label class="radio-button__label" for="btn">Text here</label>
</div>

In the CSS code below, we have some styling for the radio button:

.radio-button{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.radio-button__input{
    display: none;
}
.radio-button__label{
    border: .1em solid gray;
    font-size: 48px;
    padding: .5em;
    border-radius: 2em;
}
.radio-button__input:hover + .radio-button__label, .radio-button__input:checked + .radio-button__label{
    background-color: mediumvioletred;
}

The styling on .radio-button is only to center it, so feel free to delete it if not needed. Add a transition property on .radio-button__label for a smooth transition effect.

Answer №2

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-family: "Roboto", sans-serif;
}
.radio input {
  display: none;
}
.radio-box {
  padding: 15px 30px 12px;
  border-radius: 50px;
  color: #868aa8;
  border: 2px solid #868aa8;
  text-transform: uppercase;
  font-size: 34px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s linear;
  display: inline-block;
  margin: 0 5px;
}
.radio input:checked + .radio-box,
.radio-box:hover {
  color: #fff;
  background-color: #ea0b5b;
  border-color: #ea0b5b;
}
<label class="radio">
  <input type="radio" name="time">
  <span class="radio-box">5:30 PM</span>
</label>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Icon shrinking when de-hovered via JQuery, Javascript, and CSS techniques

Looking for a way to make three social icons grow on hover and then gradually shrink back when the user stops hovering? Wondering if there's a solution using JavaScript, CSS, or jQuery? ...

A critical bug has been discovered in Safari and Chrome where HTML5 canvas fails to work in a specific scenario, while Firefox performs perfectly

I am currently using html5 canvas to develop a function-graph software. There seems to be a critical bug that I cannot figure out. For example, when I use the following code: yOFxGraph(plotFUNCinputYofX,-4,5,-4,4,"rgb(66,44,255)",1); everything operates ...

Issues with JQuery Ajax rendering in browser (suspected)

I'm encountering an issue on my webpage. I have a div with two hidden fields containing values of 0 and 2, respectively. Upon clicking a button that triggers an AJAX query, the div contents are updated with hidden field values of 1 and 2. However, it ...

When sending an ajax request with HTML data as the payload

While working on an MVC program, I encountered an issue when trying to send data from a TextArea to the controller upon a button click. Everything worked fine until I had HTML-based data inside the TextArea. Here's a snippet of the HTML code: <te ...

Can you please provide me with a Java code snippet to fetch the source HTML

My Java request is missing some source in the response, causing the Json object to fail. HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet( "http://url?"+params); HttpResponse response = client.execute(request); Buffered ...

Utilize Jsoup to retrieve a specific value from a designated HTML source

I am currently working on a project that involves extracting all currency values and their corresponding names from a specific website. These extracted values need to be stored in two separate arrays. While researching online, I came across some code snip ...

Add a CSS class to an innerHTML element just a single time

I currently have 2 files available: data.php page.php The data.php file is responsible for fetching a row from a SQL database and sending it to the page.php file. Within the page.php file, there is a JavaScript script that receives this row through AJAX ...

Utilizing conditional statements in Vue.js for dynamic rendering

Looking for some assistance, thank you. I am struggling with writing the correct condition in Vue for my task. I have two values: content.Image & header.Background Essentially, what I need to do is check if there is a JPEG assigned to content.Image ...

Dynamic Dropdown Menu Using PHP and jQuery

I was trying to implement a tutorial I found on this website for a car-related project, but I encountered an issue. The tutorial was working fine, but I needed to add a 'Go' button to allow users to view the selected car from the drop-down menu. ...

Implementing conditional CSS class application in React JS

Lately, I've been pondering the most effective way to apply a CSS class conditionally in React JS. While I have come across some suggestions on this topic, they seem scarce or not as detailed as I had hoped for. ...

What is the best way to create a sharp perpendicular edge in the middle of a div using CSS?

I'm looking to create a div similar to this design. https://i.sstatic.net/8k9kz.png After trying various methods, I can't seem to get the edge of the Twitter circle to show up in the middle. Can anyone provide guidance on how to achieve this? T ...

Sending selected checkbox values to another JSP page with the help of JavaScript

I have some JSP code that I need help with. How can I pass checked checkbox values from a.jsp to b.jsp using JavaScript? Any assistance would be greatly appreciated. <html> <head> <meta http-equiv="Content-Type" content="text/ ...

Creating a unique button for STRIPE payments in Laravel 5.1

I have a Stripe payment button in my ecommerce website that looks like this: <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_yNuawoy0jUqj1GC14jwcQR5d" data-amount="{{ $total * 100}}" data-name="dixard" data ...

How can I use PHP to load a specific HTML element and only show a limited number of characters from it?

Just a heads up: I'm pretty new to PHP and not super familiar with this code. I stumbled upon it online and tweaked the links and ID, but now I need some help. I'm trying to figure out how to display a specific HTML element, like a paragraph wit ...

An image overlaying a background design featuring a navigation bar and company logo

Is there a way to stack images on a background image similar to this using HTML? There is also a navbar and logo on the background. I attempted to do something like this: //clearfix .image-stack::after { content: ' '; display: table; clear ...

Partially filling circles for a personalized coin-slider experience

Looking to create a unique coin-slider that changes the filled factor of a coin as it moves through a specific range of images. For example, when scrolling through 10 images, the filled part of the coin would transition from 0 to 1 depending on which image ...

What is the best way to transform the hashMap<String, String> into a practical JavaScript object?

To make a long story short. The backend team has provided me with a hashMap that looks like this: {12=Other Services (Assisted), 2=Other Services, 4=Collect, 17=Get New (For Me), 19=Get New (For My Business)} As a front-end developer, I am not familiar ...

Is the see-through sticky header going to overlay the main banner?

I recently completed developing a client's website using Squarespace. Now, I am looking to design a header that: 1) Initially has a transparent background upon the user's arrival on the page 2) Transitions to a solid background color and sticks ...

What is the best way to transform the data received from this function into a DataTable that can be used with the Google Charts API?

Is there a way to easily convert the data returned by this function into a format that Google Charts API can read? public function ajax_get_dates(){ $data = ([['date1' => '04/08/2016'], ['date2' => '05/08/2016& ...

Issue with Modal Display in Bootstrap 5

I am experimenting with opening a modal when an image is clicked using the following code snippet: <!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target=&quo ...