Can the overlay be positioned above a div with multiple rows at times?

I am facing a challenge in positioning an overlay over a div. Previously, I had the code working perfectly when the div was confined to just one row. However, I am now struggling to determine the correct height of the div when it spans multiple lines. It seems that the div reports its height as a single row but displays as multi-line after rendering.

function InitializeControls() {
    console.log("Width: " + $('#PlanViewControls').width());
    console.log("Height: " + $('#PlanViewControls').height());

    console.log("innerHeight: " + $('#PlanViewControls').innerHeight());
    console.log("outerHeight: " + $('#PlanViewControls').outerHeight());

    $('#PlanViewControls').show();

    $('#PlanViewControlsOverlay')
        .stop()
        .show()
        .css({ opacity: .7 })
        .width($('#PlanViewControls').width())
        .height($('#PlanViewControls').height())
        .offset($('#PlanViewControls').offset())
}

#PlanViewControlsOverlay
{
    background: white;
    opacity: 0.7;
    filter: alpha(opacity=70);
    position: absolute;
    z-index: 10001;
}

#PlanViewControls
{
    display: none;
    min-height: 20px;
    margin-bottom: 5px;
    
    width: 100%;
    min-width: 200px;
    overflow: hidden;
    padding: 5px;
}

#PlanViewControls > div
{
    display: inline-block;
    min-height: 20px;
}

<div id="PlanViewControlsOverlay"> 
</div>

<div id="PlanViewControls" class="ui-widget ui-state-default ui-corner-all">
    <div class="separated" style="padding-top: 3px">
        <div id="PlanViewZoomSlider"></div>
    </div>
    <div class="separator">|</div>
    <div class="separated">
        <label>
            Rack Info: 
            <select id="RackInfoSelect">
                <option value="Name">Name</option>
            </select>
        </label>
    </div>
    <div class="separator">|</div>
    <div class="separated" style="padding-top: 4px">
        <label>
            Enable Auto-Refresh:
            <input id="PlanViewRefreshCheckbox" name="Enable Auto-Refresh" value="value" type="checkbox" />
        </label>
    </div>
    <div class="separator">|</div>
    <div class="separated">
        <label>
            Levels To Display:
            <select id="LevelSelect">
                <option value="All">All</option>
            </select>
        </label>
    </div>
    <div class="separator">|</div>
    <div class="separated" style="padding-top: 3px">
        <a id="ExportPlanView" href="javascript:void(0)" target="_blank" title="Export the plan view as a pdf.">
            <span class="cs-icon cs-icon-edit-search-results" style="float: left; margin-right: 5px;"></span>
            <label id="ExportLabel">Export</label>
        </a>
    </div>
</div>

Can anyone suggest how to retrieve these measurements accurately?

Answer №1

I have taken your code and placed it in a JavaScript fiddle. I made corrections to the problematic part that JSLint identified, and also ensured that it is wrapped inside a .ready() function for proper execution.

Feel free to check it out from this point onwards and see if it resolves your issue. While I haven't provided a direct answer, asking more specific questions will assist in pinpointing the problem (:

Answer №2

Avoid using JavaScript altogether!

Simply copy and paste the #PlanViewControlsOverlay into the #PlanViewControls div. By doing this, you can utilize a percentage-based width and height to cover the entire area.

All you have to do is include these lines of code in your CSS and remove the display: none;.

#PlanViewControlsOverlay
{
    background: white;
    opacity: 0.7;
    filter: alpha(opacity=70);
    position: absolute;
    z-index: 10001;

    width: 100%;
    height: 100%;
    display: block;
}

For reference, here is an example: http://jsfiddle.net/uJrLT/21/

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

The ArcGIS JavaScript ClassBreaksRenderer does not seem to be functioning properly as the layer is only displaying the

Having an issue with my ArcGIS map where only the default symbol is rendering when I add a ClassBreaksRenderer to my GeoJSONLayer. // Color Logic const low = { type: "simple-fill", color: "#fc8d59", style: "solid&q ...

"Exploring the intricacies of API request methods in the ME

Currently, I am engrossed in Simon Holmes' book titled 'Getting MEAN with mongo, express, angular and node'. It's a fantastic read so far, but one major question has been nagging at me which the book doesn't seem to address. Holmes ...

Steps to create a responsive iframe for Slideshare

Recently, I included a slideshare iframe presentation on my webpage. Here is the code snippet I used: <iframe src="//www.slideshare.net/slideshow/embed_code/key/HQoiz6GR1oLe1n" width="860" height="600" frameborder="600" marginwidth="0" marginheight="0 ...

What is the top choice for creating a shallow copy of an array

While delving into the vue source code today, I stumbled upon a method of writing that left me puzzled. view source const deduped = [...new Set(pendingPostFlushCbs)] My initial thought is that it is a shallow copy of the array. But why is there a need t ...

There was a hiccup during the gulp build process specifically on the gulp

When I run gulp build, I encounter a specific error in the CLI events.js:141 throw er; // Error event not handled ^ Error: E:\Projects\gulp\css\styles.min.css:546:10: Missing semicolon ←[90m 544 | ←[39m b ackground ...

CSS Causing Scroll Bars to Appear When Browser is Maximized

I've noticed that the scroll bars are still visible even when I maximize the browser window. I don't see any reason for them to be there. There doesn't seem to be a height issue, so the vertical scrollbars shouldn't be appearing, right ...

What is a way to prevent animations from triggering until the previous one is complete without relying on callbacks?

My function is named: this.makeStuffHappen() This function triggers various animations based on a switch statement and some variables. I am wondering if it's feasible to prevent the function from executing unless all previous actions hav ...

What is the best way to invoke a method from CodeFile with Bootstrap in C# using Visual Studio 2013?

Working on an aspx page using VS 2013 with a C# CodeFile. If Bootstrap is applied to the page, how can I reference the CodeFile to call a function? For example, when a button is clicked to handle it through a Button1_Click function in the CodeFile: <as ...

Tips for sending HTML information to a .aspx document and storing it

I am looking to create some dynamic controls in ASP.NET, so I have created an HTML file and used JavaScript to repeat these controls. Now my challenge is how to post the data entered into these controls to an .aspx file and save that data into a database ...

Issue with Bootstrap collapsible menu not expanding when clicked

I want to make my collapsed navbar menu expand when clicked on a small screen. I've customized a Bootstrap navbar to split my links at each end of the bar. Right now, the links collapse when the screen size decreases, but clicking on the accordion but ...

a pathway leading to the user's profile

I have successfully implemented a code that displays a list of people who are at level 8, which can be seen below https://i.sstatic.net/bJ9VX.png Now, I want to make it so that when a user clicks on the username of the individuals listed, they will be re ...

Cloning dynamic drop downs causing them to malfunction

Currently, I have a table featuring just one row with two drop-down menus. The second drop-down's options are dependent on the selection made in the first drop-down via a JQuery change event. Following the table, there is a button that enables users t ...

Missing td data when using Beautiful Soup to parse HTML tables in Python

When attempting to extract a table using Beautiful Soup, I encounter an issue. from selenium import webdriver from bs4 import BeautifulSoup import pandas as pd import numpy as np import lxml import xlrd HorseNo = ["T421"] ...

How can I fetch dependent data via AJAX within a multi-select dropdown using Bootstrap and PHP?

Would you like to know how to implement a multi-select dependent drop-down using Bootstrap Multi-Select? https://i.sstatic.net/ISlqn.png If a state is selected, do you want the corresponding cities to populate the city drop-down box? Below is my AJAX co ...

Displaying a label in AngularJS and Ionic based on the current scroll position

I am facing a challenge with an ion-content scrollable item that contains anchors to jump to specific positions. In addition to the ion-content, there is also a button outside that allows users to jump to the next position. Here's an example: Jump ...

What is the best way to extract the modal into its own file?

Greetings, fellow React developer who is new to the field! I have successfully implemented a React Class Component that includes a popup Modal. This Modal displays when a user clicks on an Item Card: import React from 'react'; import { Card, Bu ...

In JavaScript, what do we call the paradigm where a variable equals a variable equals a function? Let's take

Feeling a bit overloaded at the moment, so forgive me if this question seems too simple. I managed to accidentally write some code in Jest for testing a Vue application that actually works: const updateMethod = wrapper.vm.updateMethod = jest.fn() expect(u ...

Error in simulated server - Unsupported MIME type detected for the script: 'text/html'

I encountered an error while running my app. The error can be viewed at this link: https://i.sstatic.net/u38PO.png The version of MSW I am using is 0.39.2. My MSW file is located in the public folder, accessible through this link: https://i.sstatic.net/q ...

An argument error in IE 8 caused by an invalid procedure call

Is there a way to access the opener's class in a child window created using window.open? This works smoothly in W3C browsers, but fails in IE 8. On the other hand, I tested using an iframe and it seems to work fine across all browsers. The main goal o ...

Leverage the power of jQuery's filter feature

<div class="main"> <a title="here" href="http://google.com">google.com</a> <a title="sss" href="www.sss.com">sss</a> <a title="sss" href="www.sss.com">sss</a> <a title="sss" href="www.sss.com"> ...