css issue with focus on ie11

    <style type="text/css">
    .main {
        position: absolute;
        border-radius: 8px;
        border: none;
        height: 54%;
        top: 35%;
        /*33%*/
        color: #FFFFFF;
        font-size: 0.7em;
        overflow: hidden;
        z-index: 50;

    }
    .test1 {
        display: inline-block;
        height: 100%;
        width: 100%;

    }
    .test2 {
        display: inline-block;
        height: 100%;
        width: 100%;
    }
    .main:focus {
        z-index: 55;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        outline: none;
        top: 20%;
    }

</style>
<div>
    <!--other element-->
    <div class="main" tabindex="0">
        <div class="test1">
            <!--other element-->
        </div>
        <div class="test2">
            <div class="abc">
                <!--other element-->
            </div>
            <div class="abc">
                <!--other element-->
            </div>
        </div>
    </div>
</div>

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>    .main {
           
           position: relative;
           
            height: 120px;
          
            z-index: 10;

        }
        .test1 {
            
            height: 70%;
            

        }
        .test2 {
         
            
            height: 80%;
            
        }
        .main:focus {
            z-index: 22;
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
            outline: none;
            top: 25%;
            background-color: blue;
          }
    <div>
        <!--other element-->
        <div class="main" tabindex="0">
            <div class="test1">
                <span>Content1</span>
            </div>
            <div class="test2">
                <div class="abc">
                    <!--other element-->
                    <span>Content2</span>
                </div>
               <div class="abc">
                    <span> Content3</span>
                 
                </div>
              
            </div>
                      
    
    
     </div>

Answer №1

To ensure that the main container receives focus when clicking on the .main container, you will need to remove the width and height properties from the test1 & test2 classes. Your updated style should resemble the following:

.main {
            position: absolute;
            border-radius: 8px;
            border: none;
            height: 54%;
            top: 35%;
            /*33%*/
            z-index: 50;
        }
        .test1 {
            /*display: inline-block;*/
        }
        .test2 {
          /*display: inline-block;*/
        }
        .main:focus {
            z-index: 55;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            outline: none;
            top: 20%;
            background-color: red;
        }

Alternatively, if you wish to give focus to the .test1/.test2 class, you can use the following code:

.main .test1:focus {
........
}

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

Is it possible to modify the background color of the firefox address bar according to the type of protocol being used?

Is there a way to customize the background color of the address bar in Firefox according to different protocols? For example, using blue for https, orange for mixed content warning, green for ev-certificate, and red for invalid certificates. ...

Ways to showcase the chosen image from the input field?

Can someone help me with an issue I'm having regarding displaying selected images? Every time I try, I encounter this error message: Not allowed to load local resource: Any suggestions or insights into why this might be happening? <input type=&a ...

Enhancing Bootstrap with VueJS for better component ordering

I've been struggling with Vue components in Bootstrap lately. I am attempting to create collapsible Bootstrap content in Vue, and here is the current code: HTML <div class="col-sm main-content" id="main-content"> <p&g ...

Tips for adding CSS attributes to a <style> tag in Internet Explorer

My current issue involves an ajax web application that loads all parts on a single page, specifically index.html. The inner parts being loaded in index.html have exceeded 32 pages (html, js, css). Now I am facing difficulties with the CSS files that need ...

A Guide to Harvesting Email Addresses with Python and Selenium

Is there a way to use selenium to extract the 'email' field from a specific box? I need to retrieve the value="[email protected]". Any suggestions on how this can be accomplished? Check out the website here: https://i.stack.imgur.com/KNXK0 ...

What is the best way to retrieve the value of a component's HTML id tag in React?

Is there a way for me to retrieve the id of a react component from within the component itself? I need this information to perform some tasks with a third-party library. In Ember, you can access the component's id using elementId, which can be found ...

Instead of scrolling through the entire window, focus on scrolling within a specific HTML element

I currently have the following elements: #elementA { position: absolute; width: 200%; height: 100%; background: linear-gradient(to right, rgba(100,0,0,0.3), rgba(0,0,250,0.3)); z-index: 250; } #containerofA { position: fixed; ...

Using Chrome or Firefox's inspector tool to make changes to HTML code

Is it possible to save changes made to HTML elements in Chrome/Firefox inspector directly to a local file on my desktop? ...

Highlighting menu elements when landing on a page and making another menu element bold upon clicking in WordPress

I've been searching extensively for a solution to this issue. I'm trying to make the menu item DE appear bold when entering the site, and if I click on EN, I want DE to return to normal (thin) font while EN becomes bold. You can find the site he ...

Display an image with text that appears on hover along with a change in opacity

Is there a way to make the hover effect on an image display with opacity while keeping the text inside unaffected by the opacity style? The image is housed within an input tag, and when clicked, a bootstrap modal will appear with an input form. .img_wra ...

Before the <table> tag, web browsers display a mysterious Phantom <br> tag

Why is the browser inserting a <br> tag before my <table> element? The page is meant to be displayed within one table, but an unwanted whitespace is being created by this tag that is not included in the code. The code appears like this, even w ...

Designing table rows to resemble full-width cards

Looking for a way to transform the rows of a table into full-width cards while maintaining the row layout? Here's what I have tried so far: tbody>tr { display: block; padding: 1rem 0.5rem 1rem 0.5rem; margin: 1.5rem; border: 1px solid rgba( ...

Is there a way to use regular expressions to search for class names within nested div elements?

I'm struggling to find nested divs like these in my document object model (DOM) <div class="two-columns some-other-class"> <div class="two-columns some-other-class"> </div> </div> I attempted to search for neste ...

Unable to assign image src to a dynamically generated div

My current task involves setting the background URL of a dynamically created div in JavaScript, intended for use with the jQuery Orbit slider. Below is my approach: var content1 = null; $("#featured").html("<div id='content' style='&apos ...

How about utilizing node.js as a peer for WebRTC?

Are there any available modules for utilizing node.js as a peer in WebRTC? I am interested in using WebRTC in a client/server manner rather than P2P for its ability to send packets unreliably (i.e. avoiding the delay caused by TCP's guarantee of packe ...

Why does appending to a TextArea field fail in one scenario but succeed in another when using Javascript?

There is a JavaScript function that captures the value from a select dropdown and appends it to the end of a textarea field (mask) whenever a new selection is made. function addToEditMask(select, mask) { var selectedValue = document.getElementById(sel ...

Javascript error specific to Internet Explorer. Can't retrieve the value of the property 'childNodes'

After removing the header information from the XML file, the issue was resolved. Internet Explorer did not handle it well but Firefox and Chrome worked fine. An error occurred when trying to sort nodes in IE: SCRIPT5007: Unable to get value of the proper ...

How can I incorporate a fade opacity effect into my Div scrolling feature?

I successfully implemented code to make div elements stick at the top with a 64px offset when scrolling. Now, I am trying to also make the opacity of these divs fade to 0 as they scroll. I am struggling to figure out how to achieve this effect. Below is ...

How to perfectly align content on a webpage

Can someone help me understand why my webpage is off-centered as it scales up? I have set a minimum width of 1000px, but it still appears to be centered at 30%-70%. Any insights on this issue would be greatly appreciated. <!DOCTYPE html PUBLIC "-//W3 ...

WindiCSS classes are not functioning properly within a Nuxt application

I've been encountering some difficulties with WindiCSS. The classes are not being applied to the elements as expected. I attempted to install an older version of Windi, but the issue persisted. I even tried switching to Tailwind instead of Windi, but ...