Hover Problem with HTML Image Tag

Having trouble understanding why the images are not changing color on hover. The images are svg files and should be able to adopt the color. Here is the code snippet:

HTML:

<div class="toolTile col-md-3">
    <a href="#/cards">
        <img src="ppt/assets/toolIcons/requestnewcard.svg" >
        <p>Manage my debit card</p>
    </a>
</div>        
<div class="toolTile col-md-3">
    <a href="#/recurClaim">
        <img src="ppt/assets/toolIcons/recurring.svg" >
        <p>Recurring Claims</p>
    </a>
</div> 

And corresponding CSS:

.toolTile {
    height: 200px;
    float: left;
}

.toolTile img {
    color: #ab2328;
    height: 100px;
    width: 93px;
    margin-left: auto;
    margin-right: auto;
    display: block;
}

.toolTile img:hover {
    color: yellow;
}

Answer №1

When it comes to text elements, color plays a significant role. However, if you are looking to emphasize them further, adding a border might be the solution.

.toolTile img:hover {
    border: Yellow 1px solid;
}

If you want to see it in action, check out this JSfiddle: https://jsfiddle.net/td70mqq5/

If this isn't exactly what you had in mind, consider exploring the use of SVG with svg {fill: currentColor;} (https://css-tricks.com/cascading-svg-fill-color/)

Answer №2

CSS rules are not carried over from one document to another. Thus, the styles specified in your HTML file will not affect the appearance of external SVG files.

To address this issue, you can choose to embed the SVG directly within your HTML code or transfer the styling information to the SVG file(s) and replace <img> tags with <object> elements.

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

Conceal the slider thumb within the material-ui framework

I've been attempting to conceal the slide thumb, initially without using a library. However, I started considering utilizing material-ui as it might make the process easier. Hence, I'm seeking assistance here. Below is my code snippet: import * ...

Filter a div based on multiple conditions using JavaScript/jQuery

In my filtering system, I have two sections: place and attraction. When I select a place, the corresponding div is displayed according to the selected place. Similarly, when I select an attraction, only the attractions are filtered accordingly. <ul clas ...

Is there a way to change the background color of a redirected page by clicking on a tag?

I have a specific goal in mind: when clicking on an anchor tag, it should redirect to page2.html and change the background color of a particular div on that page. (The anchor tag contains a URL and an ID in its href to direct to a specific section.) pa ...

Styling the right button of the split button in jQuery Mobile version 1.4.0 using CSS

I was attempting to create a listview with list items that have a button on the right side, much like a jQuery Mobile split button listview. However, I only want the right button to be clickable. The left part of each item should contain a label along with ...

Is there a way for JavaScript to automatically detect various display sizes and redirect users to different websites based on their screen dimensions?

I recently completed a new website and noticed that it looks quite strange on mobile devices, with overlapping divs causing issues. I tried implementing this code: window.addEventListener("resize", function(){ var width = window.innerWidth || ...

struggling to perfect the CSS styling

I am in need of a design similar to the image linked below: https://i.sstatic.net/Er1wT.png I attempted to create this layout using a table, but I have not been successful in aligning the side images properly. testTable.html <style> .container{ ...

An issue has been detected where the bullet list is uneven due to the CSS property/value columns being set

Is there a more effective way to split a bulleted list into two columns than the method I am currently using and ensure that the columns are aligned at the top? .hand-bullet-list ul{ list-style-type: none; margin-left: 0px; } .hand-bullet-list ...

Troubleshooting issue with applying Select2 class dynamically with JavaScript

When developing my web application, I faced a challenge of dynamically adding new rows to a table using JavaScript. The row contains a <select> element which loads data from the ViewBag for its <options>. Additionally, I wanted to apply the Sel ...

Arranging my table

I've been trying to adjust the position of a table in my project that contains an image. Currently, it is aligned to the left and I want to move it to the right. Here is the code for my table: <TD> <IMG SRC='http://farm8.staticflickr.co ...

Is it possible to leverage the flex features of react-native in a manner similar to the row/column system of

Is it a good idea to utilize flex in react native by creating custom components that retrieve flex values? I previously used the bootstrap grid system and now I am exploring react native. Is there a way to implement this example using react-native bootstr ...

iPhone 5s landscape mode causing issues with media query

I have been testing a media query that looks like this: @media screen and (max-width: 600px) { .blah { font-size: 1.25rem; } } When I test this in responsive mode on browser dev tools, everything looks great. I can see all the changes as I resize ...

What is causing the data element to remain unchanged within a Vue.js function and what steps can be taken to ensure its value can be updated?

Using the axios API in the created() function, I am able to access webURLs. When a mouseover event triggers a v-for handler in the HTML file, the index is obtained and assigned to the selectedState data element. Although the value of selectedState changes ...

Retrieve the input name array key value using jQuery from the adjacent TD

It's a tough one to summarize in the title, but here is the code snippet that explains it: <tr class=""> <td> <input value="9" name="set[122][order]"></input> <input class="set-id ...

Showcase the loop field of Advanced Custom Fields

I've been struggling to get a repeater field consisting of images to show up on my WordPress template, but it's just not cooperating. I even went through the documentation of the plugin: Unfortunately, I still can't seem to get it to functi ...

Trigger Click event when clicking on navigation link using the ID

Currently, I am working with a WordPress theme that includes a page with 10 tabs that open individually. My approach so far has been to provide links to all tabs in the navigation bar. For instance, href="mylink.com/#tabid" It works perfectly when the p ...

Creating a button with multiple background gradients using CSS

When working on a button element that already boasts a gradient effect, my aim was to integrate a small play image directly in the center. However, achieving this without compromising the current layout and ensuring compatibility across various browsers pr ...

"Placing the save button on top of a div - a step

I am trying to position a div with an ID below a save button in my HTML code. The current setup looks like this: <button id="item_new" data-action="create" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button- ...

Is it possible to override a div class and apply a different css class using jQuery, even if the names are duplicates

My goal is to customize a specific class within a group of elements that have the same class name, based on whether it contains specific text or not. While I have successfully used addClass in jQuery, the challenge I now face is that the main CSS class is ...

Displaying an alert when the text box contains a duplicate value

I have a set of input fields with various values that can be edited but must not be left empty (if left empty, display an alert). When I update a field with a new value, if that new value matches any of the other input field values, I want to display an al ...

Is there a button for invoking a PHP function?

I am fresh to the javascript realm. I've created a function in PHP. How can I trigger it by clicking a button or image in HTML? ...