Trouble with :active CSS selector not functioning when clicking on child element in IE8

I am dealing with the following HTML structure:

<div id="ctr__Wrapper" class="wrapper">
    <div id="ctr" class="control clickable">
        <img src="logo.png">
    </div>
</div>

Here is the CSS code for this setup:

.control
{
    border: 1px solid #000;
    background-color: #666;
    padding: 20px;
}

.control:active
{
    background-color: #bbb;
}

Upon clicking on the "ctr" element, I observe a change in background color. However, when I click on the image itself, no effect is seen. This behavior is consistent in Firefox but not in IE8. Are there any CSS solutions for this issue?

To see a working example, please visit: http://jsfiddle.net/miljenko/DNMPd/

Answer №1

You have the option to utilize a background image in place of an actual image.

html:

<div id="ctr__Wrapper" class="wrapper">
    <div id="ctr" class="control clickable">
    </div>
</div>

css:

.control
{
    border: 1px solid #000;
    background-color: #666;
    height: 40+height-of-logopx;
    background-image:url(logo.png); background-repeat:no-repeat;
    background-position:20px 20px;
}

.control:active
{
    background-color: #bbb;
}

Answer №2

As a result of the lack of support for :active in anything other than anchor elements, usage may be limited in versions of IE9 and below. For a solution that works in IE8, you can refer to this fiddle: http://jsfiddle.net/jalbertbowdenii/DNMPd/12/

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

Customizing the appearance of Twitter Bootstrap based on the AngularJS input class $invalid

I'm struggling with getting error messages to display properly in my Bootstrap form when using AngularJS. I followed the instructions on this link: but I still can't figure out what I'm doing wrong. Any advice? Thanks <div class=" ...

Retrieve the HTML document and all its elements

Is there a method in Python to save an entire webpage with all its contents (images, css) to a local directory using a URL? Additionally, is it possible to update the local HTML file to reference the locally saved content? ...

Incorporate adjustable div heights for dynamically toggling classes on various DOM elements

One of the challenges in developing a chat widget is creating an editable div for users to input text. In order to maintain the design integrity, the box needs to be fixed to the bottom. An essential requirement is to have javascript detect resizing as us ...

Turn off the ability to view the content of .css and .js files within the browser

Earlier, I inquired about how to disable file and folder listing and discovered that it can be achieved using a file named .htaccess. To disable folder listing, I entered Options -Indexes in the .htaccess file located in the parent folder. Additionally, to ...

Struggling with resizing a webcam feed to fit the dimensions of the iframe container?

I'm facing a challenge embedding a camera feed into a webpage that needs to display manual focus and servo controls. The issue lies in the content scaling within the iframe. Even though the iframe boundary resizes according to the window's width ...

Is there a difference in performance between using multiple inline scripts versus one combined inline script?

Comparing Multiple Inline Scripts to a Single Conjoined Inline Script: <script type="text/javascript">/* some codeblock 1 */</script> <script type="text/javascript">/* some codeblock 2 */</script> <script type="text/javascript"& ...

What could be the reason for JQuery not updating the CSS class?

Seeking assistance with a jQuery issue. When clicking a link in the navbar, I am attempting to change its style (background and font color). Here is the code I am using: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery ...

Video streaming platform without the need for javascript and plugins

Is it feasible to watch Youtube videos without relying on javascript and plugins, exclusively using HTML5 or a similar alternative? ...

What causes a header to appear transparent when it has a background color set in HTML?

I'm attempting to create a webpage that resembles Gmail. I have a header with a background color, but when I scroll, the content in the body becomes visible. Here is the view without scrolling: https://i.stack.imgur.com/UQ2sO.png However, while scr ...

Issues encountered when incorporating personalized CSS into a Vuetify element

Working with the Vuetify selector input component, v-select, and wanting to customize its style led me to inspecting it in Chrome and copying down the necessary classes. For instance, to change the font size of the active value, I utilized: .v-select__sel ...

An unidentified element is displayed as undefined

I am trying to implement a CSS change for mobile devices, but an unknown variable keeps showing up as undefined. Despite researching various tutorials and finding multiple solutions, I am struggling to grasp them as I am a novice in JavaScript and HTML. T ...

My project is experiencing issues with the execution of JavaScript codes

Greetings, I'm having trouble with my JavaScript codes. The following code works perfectly: function Choice() { var box = document.getElementById('searchh'); if (!count) { var count = 0; } box.onclick = function () ...

Is it possible to resize an object using JavaScript?

Is it possible to change the size of an object when loading specific data by clicking on navigation? <object id="box" width="250" height="250" data=""></object> Although the JS code loads the data, it does not change the size. document.getEl ...

Change the dropdown menu text to show the selected option text once the page has been redirected

Hey there, I am looking to dynamically update the dropdown text with the selected option after a page redirect and reload of the dropdown. Check out my code below: <div class="sorting-option"> <select id="selectdropdown" class="dropdown-selec ...

Tips for unchecking a checkbox when another checkbox is checked in Angular

My table displays a list of deleted items. Users have the option to either recover the item or delete it permanently. I am seeking assistance in ensuring that only one checkbox is checked in a table row, and unchecking other checkboxes if the user tries t ...

Animate the object in SVG with periodic movements

Illustrate once and move items every five seconds in the sequence shown from left to right. I have looked extensively but cannot find a method to draw outer boundaries and position objects close to them. <animate xlink:href="#blue-rectangle" a ...

Is it possible to assign a name attribute to the <img> tag in HTML?

Can the "name" attribute be used in an "img" tag in HTML? If you have this knowledge, please do share and thank you in advance. ...

Tips on configuring commas in the Prettier extension within Visual Studio Code

My CSS file is causing me some trouble. I am trying to configure Prettier in VS Code so that when I write a comma, the selector I entered stays in line with the previous one. However, whenever I save the file, the selector gets moved to the next line. My ...

CSSS not generating proper mappings/compiling

After finally finding some time to delve into web design, I encountered a frustrating issue with my SCSS code failing to compile. Ugh. The first red flag was when my changes weren't appearing in the live preview on Brackets. Upon inspecting the corre ...

Utilize DOM to attach a button onto an image

I am looking to add buttons onto images using DOM manipulation. Each image will have multiple buttons that, when clicked, will delete the image. I am aiming for a functionality similar to this example - JSFiddle This is the code I have attempted so far: ...