Adjusting the cursor to switch to a pointer when hovering over a span inside

I've implemented custom CSS styling for radio buttons on a website by following a guide (referenced from here), but I'm encountering difficulties in changing the cursor to a pointer when hovering over the label and span elements within the label that styles the radio button appearance.

Markup

<div class="demonstration pureCSS">
  <div>
    <input id="checkboxPureCSS1" type="checkbox" name="checkboxPureCSS" value="1" checked="checked"><label for="checkboxPureCSS1"><span></span>Option 1</label>
  </div>
  <div>
    <input id="checkboxPureCSS2" type="checkbox" name="checkboxPureCSS" value="2"><label for="checkboxPureCSS2"><span></span>Option 2</label>
  </div>
  <div>
    <input id="checkboxPureCSS3" type="checkbox" name="checkboxPureCSS" value="3"><label for="checkboxPureCSS3"><span></span>Option 3</label>
  </div>
</div>

<br />

<div class="demonstration pureCSS">
  <div>
    <input id="radioPureCSS1" type="radio" name="radioPureCSS" value="1" checked="checked"><label for="radioPureCSS1"><span><span></span></span>Option 1</label>
  </div>
  <div>
    <input id="radioPureCSS2" type="radio" name="radioPureCSS" value="2"><label for="radioPureCSS2"><span><span></span></span>Option 2</label>
  </div>
  <div>
    <input id="radioPureCSS3" type="radio" name="radioPureCSS" value="3"><label for="radioPureCSS3"><span><span></span></span>Option 3</label>
  </div>
</div>

CSS

.pureCSS input[type=checkbox]:not(old),
.pureCSS input[type=radio   ]:not(old){
  width     : 2em;
  margin    : 0;
  padding   : 0;
  font-size : 1em;
  opacity   : 0;
}

.pureCSS input[type=checkbox]:not(old) + label,
.pureCSS input[type=radio   ]:not(old) + label{
  display      : inline-block;
  margin-left  : -2em;
  line-height  : 1.5em;
  cursor: pointer;
}

.pureCSS input[type=checkbox]:not(old) + label > span,
.pureCSS input[type=radio   ]:not(old) + label > span{
  display          : inline-block;
  width            : 0.875em;
  height           : 0.875em;
  margin           : 0.25em 0.5em 0.25em 0.25em;
  border           : 0.0625em solid rgb(192,192,192);
  border-radius    : 0.25em;
  background       : rgb(224,224,224);
  background-image :    -moz-linear-gradient(rgb(240,240,240),rgb(224,224,224));
  background-image :     -ms-linear-gradient(rgb(240,240,240),rgb(224,224,224));
  background-image :      -o-linear-gradient(rgb(240,240,240),rgb(224,224,224));
  background-image : -webkit-linear-gradient(rgb(240,240,240),rgb(224,224,224));
  background-image :         linear-gradient(rgb(240,240,240),rgb(224,224,224));
  vertical-align   : bottom;
}

.pureCSS input[type=checkbox]:not(old):checked + label > span,
.pureCSS input[type=radio   ]:not(old):checked + label > span{
  background-image :    -moz-linear-gradient(rgb(224,224,224),rgb(240,240,240));
  background-image :     -ms-linear-gradient(rgb(224,224,224),rgb(240,240,240));
  background-image :      -o-linear-gradient(rgb(224,224,224),rgb(240,240,240));
  background-image : -webkit-linear-gradient(rgb(224,224,224),rgb(240,240,240));
  background-image :         linear-gradient(rgb(224,224,224),rgb(240,240,240));
}

.pureCSS input[type=checkbox]:not(old):checked + label > span:before{
  content     : '✓';
  display     : block;
  width       : 1em;
  color       : rgb(153,204,102);
  font-size   : 0.875em;
  line-height : 1em;
  text-align  : center;
  text-shadow : 0 0 0.0714em rgb(115,153,77);
  font-weight : bold;
}

.pureCSS input[type=radio]:not(old):checked +  label > span > span{
  display          : block;
  width            : 0.5em;
  height           : 0.5em;
  margin           : 0.125em;
  border           : 0.0625em solid rgb(115,153,77);
  border-radius    : 0.125em;
  background       : rgb(153,204,102);
  background-image :    -moz-linear-gradient(rgb(179,217,140),rgb(153,204,102));
  background-image :     -ms-linear-gradient(rgb(179,217,140),rgb(153,204,102));
  background-image :      -o-linear-gradient(rgb(179,217,140),rgb(153,204,102));
  background-image : -webkit-linear-gradient(rgb(179,217,140),rgb(153,204,102));
  background-image :         linear-gradient(rgb(179,217,140),rgb(153,204,102));
}

I have reproduced the issue in a jsfiddle, where the cursor reverts to its default appearance when hovering over the radio buttons. Despite trying to set cursor: pointer on span:hover, this change did not take effect. Is there a way to make the cursor remain as a pointer when hovering over the radio buttons?

Answer №1

Simply include a touch of optimism that might do the trick.

input[type=radio]:hover{
  cursor: pointer;
}

Answer №2

Include cursor: pointer;

.customCSS input[type="checkbox"]:not(old), .customCSS input[type="radio"]:not(old) {
    cursor: pointer;
    font-size: 1em;
    margin: 0;
    opacity: 0;
    padding: 0;
    width: 2em;
}

Link to example

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

Utilizing the hcSticky plugin for creating a scrolling effect on webpage content

I'm attempting to utilize the JQuery plugin, hcSticky, in order to achieve a scrolling effect on my fixed content. However, I seem to be encountering some difficulty getting it to function properly. What could I possibly be doing incorrectly? JSFIDDL ...

CSS: Only apply the style to elements that have both specified classes, without affecting any elements with other classes

Here is the code snippet I'm using to inject a style that should be applied to a Div containing both the styles: .noindex and .ms-wpContentDivSpace <script> $(document).ready(function(){ $('.noindex, .ms-wpContentDivSpace')..css({ ...

Tips for displaying a loading spinner each time the material table is loading

Hey there, I'm currently working on an Angular project where I need to display a table using Material Table. To indicate that the table is loading, I've defined a variable called isLoading. Here's how it works: In my TypeScript file: @Com ...

Transition one background image into another using background positioning

Snippet of code: https://jsfiddle.net/foy4m43j/ HTML: <div id="background"></div> CSS: #background { background-image: url("http://i.imgur.com/hH9IWA0.png"); background-position: 0 0; background-repeat: repea ...

What is the best way to fill out a secondary drop

Is it possible to dynamically populate a secondary selection based on the User's choice in the first selection? For example, if the user selects "Silver," how can I automatically remove "Silver" from the second selection options? var b = { img: ...

Implementing HTML page authentication with Identity ADFS URL through JavaScript

I have a basic HTML page that displays customer reports using a JavaScript function. The JavaScript makes an ajax call to retrieve the reports from a backend Spring REST API. In the Spring REST API, I have set up an endpoint "/api/saml" for authentication ...

Angular Material is being improperly utilized by misusing the <label for=FORM_ELEMENT> tag

Encountering an issue with Angular Material while attempting to incorporate a <mat-label> element within a basic <mat-form-field>: https://i.sstatic.net/zQ4pp.png Below is the troublesome code snippet: <mat-form-field color="accent&qu ...

Is there a way to remove specific content from a media recorder?

I have implemented the getUserMedia and MediaRecorder APIs to capture user videos. Now, I am trying to figure out how to add a button that allows users to delete the last part of their recorded stream if they paused while recording. Unfortunately, I have ...

Steps to create a toggle effect for each ion-card individually

Issue at hand: Whenever toggling, the change effect is applied to every ion card. Expected Result: I aim to achieve a toggle effect individually on each ion-card. HTML Code: <ion-grid> <ion-row> <ion-col *ngFor="let ...

loop not functioning properly with file type input

Having trouble uploading an image and copying it into a folder named images within a loop. Can you assist with solving this issue? Here's my code: $sql="SELECT * FROM product"; $q=$conn->query($sql); while($r=$q->fetch(PDO::FETCH_ASSOC)) { $cod ...

Utilizing the power of .not() to conceal all divs with the exception of the one that has been clicked on

I am currently working on a project to enlarge images that have thumbnails within divs. My issue is that when I click on an image with the .thumbnail class, it enlarges as expected but I want all other products to disappear from view. I attempted adding a ...

Experiencing difficulties with capturing the focus event of the <select> tag

I'm completely stumped at the moment... I just can't seem to get my head around how to make a jQuery $("thing").is(":focus") selector work with a <select> tag in my project. Here's what I've got so far: <input id="uText" name ...

Shifting text higher to the <h1> tag using CSS

I'm currently attempting to move the paragraph header closer to my h1 title. I'm struggling with incorporating the position function and have tried using padding without success. On the image, I am aiming to position the text "Where every connec ...

Can someone please help me understand why my CSS transform scale isn't functioning properly?

I've developed a JavaScript function that enlarges a button and then smoothly shrinks it back to its original size. The function successfully changes the color of the button to blue, but for some reason, it's not working with the transform prope ...

The presence of an image within an HTML anchor is causing an unexpected artifact to

Currently, I am working on a simple header design, but there seems to be a strange issue with the anchors containing image tags. The problem can be seen in the screenshot below: Image Link Here is the HTML structure: <div class="block-content"> ...

What causes certain website pages to go blank after multiple refreshes?

As I work on developing a website with Next.js 13 utilizing the app router, I have encountered a puzzling issue. Specific pages on my website, when refreshed multiple times, inexplicably turn completely white. The console displays a message that reads: "T ...

To grab a specific CSS attribute from a stylesheet using JavaScript

I am looking for a way to extract the value from a CSS file using a JavaScript function. Take a look at my code snippet below: HTML file -> <link rel="stylesheet" type="text/css" href="test_css.css" /> <script type="text/javascript ...

If an incorrect feedback message is displayed, the input icon will be disabled

Here is the issue I am encountering: This is the code snippet causing the problem: <div class="col-12"> <div class="form-group has-icon-left"> <label class="form-label" for="first-name-icon&quo ...

The insertion of the script string from the ajax response was unsuccessful

When working with PHP, I encountered an array with two parts: array('threeRowHtml'=> '<HTML output string>', 'jsCode'=> '<script output string>' ) I decided to return this array for my ajax call. ...

Version 4.1 of Bootstrap offers a versatile multirow card layout with two columns

How can I make a two-column, multi-row card display using Bootstrap v4.1? I need this setup three times, with each pair of cards grouped for different tasks. Please see the code below and provide assistance. body { backgroun ...