Interactive Radio Selection

How can I create a hover effect for my radio buttons? Using !important isn't working. Is there a different way to achieve this effect on the radio input fields when hovering over them? You can view the complete example on jsfiddle at line 39.

If the 5th radio button is selected and you hover over the first one, the others should turn grey while the hovered one becomes orange.

/* Filled Rating */
.rating-fill{
    width:0;
    height:100%;
    background:url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS...')
    position:absolute;
    background-size: contain;
    top:0;
    left:0;
    z-index:1;
}

/* Checked Inputs */

.radio-wrap input[value="5"]:checked + .rating-fill{
    width:100%;
}
...

http://jsfiddle.net/9q9gfob6/2/

Answer №1

Your code appears to be functioning correctly. The reason why the hover effect is not visible is because the first star is already selected with a width of 20% initially.

.radio-wrap input[value="5"]:hover + .rating-fill{
    width:100%;
}

.radio-wrap input[value="4"]:hover + .rating-fill{
    width:80%;
}

.radio-wrap input[value="3"]:hover + .rating-fill{
    width:60%;
}

.radio-wrap input[value="2"]:hover + .rating-fill{
    width:40%;
}

.radio-wrap input[value="1"]:hover + .rating-fill{
    width:20%;
}

Check out this Fiddle
The fifth input has been removed, so hovering over the fifth star will not have any effect.

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

Text vanishing upon the loading of an HTML webpage

I am experiencing an issue where the text on my webpage disappears after it loads, and I am struggling to figure out the cause. (I did not create the site) The white text displayed on top of the header image initially appears correctly but then vanishes. ...

Issue with AngularJS bug in Internet Explorer when using regular style attribute compared to ng-style

While working with Angular JS v1.1.5, I came across an interesting issue related to Internet Explorer. In IE 9, 10, 11, and Edge, the following code snippet doesn't work as expected, even though it works fine in Chrome: <div style="width: {{progr ...

Is it possible to utilize checkbox images for type="checkbox" in ng-repeat with AngularJS?

Hi there, I'm currently attempting to add a checkbox image for input type="checkbox" using ng-repeat. I've styled everything accordingly, but when I apply ng-repeat, it only works for the first item in the list. Here is what my CSS file looks lik ...

Internet Explorer fails to account for the height of table cells when using overflow-x:auto, leading to hidden content. In contrast, Chrome adjusts for this automatically. What steps can be taken to address

Chrome: https://i.sstatic.net/bzgOT.jpg Internet Explorer: https://i.sstatic.net/qHH1r.jpg The image at the top shows how the content should appear on Chrome, while the one below demonstrates how it is displayed on IE11. The issue seems to be that on In ...

Switch the visibility of an HTML input styled as a "spinner"

I have managed to create a CSS-based method for toggling the visibility of span or input elements depending on whether a radio button is checked. I got inspired by this insightful question on Stack Overflow. However, I encountered an issue where this togg ...

Verify if any choices are available before displaying the div block

I need to determine if there is a specific option selected in a dropdown menu, and then display a div if the option exists, otherwise hide it. I'm not just checking the currently selected option, but all available options. if (jQuery(".sd select opti ...

What is the best way to incorporate styled components and interpolations using emotion theming?

I've been building a React web application with a dynamic theme feature using the emotion-theming library. This allows users to switch between different environments, each with its own unique theme. To achieve this, I created my own CustomThemeProvide ...

Is there a way to set the <hr /> tag to display vertically?

Is there a way to make the <hr /> tag go in a vertical direction rather than appearing horizontally as it normally does? I am looking for a solution that can be used on a mobile site with broader compatibility across browsers, rather than relying on ...

Format for entering phone numbers

Currently working with Angular and seeking an input field that can display the text format 614-123-1234. I've been exploring options, including a jQuery solution, but unfortunately cannot integrate it into my project. This is how my current input fie ...

Troubleshooting issue with ellipsis functionality in Bootstrap using flex layout

I have been struggling to include ellipsis after displaying 2 lines of icons. I have tried different approaches and modifications, but nothing seems to work. Seeking assistance from experts to tackle this issue, your feedback is highly appreciated. .elli ...

Adjusting a Form Input Field

There seems to be an issue with the text alignment in my submission form input field, as the text appears a few pixels too low. This is causing certain letters like y, q, and j to bleed below the box in Chrome and only partially show in IE 8. To fix this p ...

Issue with iOS 10: Changes to class not reflected in CSS/styles

Currently, I am utilizing Ionic with Angular to develop an application for Android and iOS. Surprisingly, everything functions smoothly on Android, but there seems to be an issue with iOS. I am employing a class change on an element using ng-class. I can ...

What causes external CSS to take precedence over embedded CSS in my webpage?

As per a certain source, conflicting CSS styles on the same element should be overridden by embedded styles over external styles, but my observation proves otherwise. My HTML code (simplified version) is as follows: <html> <head> <link r ...

Creating a vertical scrolling marquee to showcase a list in React - step by step guide

Trying to create a marquee effect that displays a list of items in a vertical auto-scroll. After reaching the end of the list, I want it to loop back to the beginning seamlessly for continuous animation. The code snippet below shows my progress so far - a ...

What is the best way to evenly distribute items in nested CSS Grid Columns?

Check out this JSFiddle link for a simple Google.com recreation. I'm attempting to organize the top navigation bar by creating separate containers for About, Store, Gmail, and Images. The issue seems to be related to the justify-items:center; propert ...

modify the color of a box within a grid upon clicking it

I am curious if it is possible to change the color of a box when it is clicked. I am working on coding a "calculator layout" and would like to start with this part 1 2 3 4 5 6 7 8 9 0 This is what I have been working on and struggling with. $(docume ...

a non-breaking space within a hyperlink

While working on the subnavigation of a website, I encountered an issue with the link Suite «Mont Blanc», which was pulled from the backend. The desired format for this link was:       Suite «Mont Blanc» However, t ...

Is VS Code highlighting compatible with template string CSS in Emotion?

Is there a way to enable syntax highlighting for emotion's template string css in VS Code? I've been looking for plugins, but all of them seem to focus on snippets. I have tried using css({ camelCaseCssProps:...}), which works. However, I am att ...

Trouble with the visibility of the Bootstrap navigation bar menu icon

I am currently utilizing Bootstrap's navigation bar, and I have configured a menu icon. However, when I resize the browser window to a smaller size, the navigation bar functions properly but the icon does not appear. HTML: <nav id="navigation ...

Wrapper for box placement

Just starting out in web development and I'm eager to create my first webpage. I'd like to have three boxes neatly placed within my wrapper, something similar to this sketch: https://ibb.co/xGDCv2f The three boxes I want to include are "Registre ...