retrieve height of the rendered DIV

I'm currently facing an issue with a layout tool that resizes multiple divs. These divs contain a title span which is positioned at the bottom : 0. When the divs are shortened, everything appears fine, but when they are lengthened, the spans end up floating above the bottom of the div.

I have experimented with different CSS methods to try and keep the span at the bottom, but it seems that once the rendering takes place, and the freewall (the layout script) does its job, the spans refuse to go back down.

I've tried to obtain the height of the parent DIV using various techniques. When I check the console log for the div, I can see its rendered height in the element.style (height: 222.4px); however, trying to access the style only returns the applied background image, not the actual rendered height. Any attempt to retrieve the height via jQuery .height() only gives me the CSS height (200px), which is incorrect.

Do you have any suggestions on how to make sure an element stays at the bottom after a layout resize, or perhaps a way to access the rendered height so I can programmatically position it back at the bottom?

Referencing the provided CSS:

.guideScene {
    height: 200px;
    width: 200px;
    min-width: 190px;
    background-size: cover; 
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
}

@media all and (max-width: 768px) {
    .guideScene {
        height: 100px;
    }
}

.guideScene span {
    font-family: 'Lato', sans-serif;
    color: #000;
    font-weight: 700;
    font-size: 14px;
    line-height: 100%;
    min-height: 14px;
    background: #fff;
    padding: 4px 10px 4px 10px;
    bottom: 0px;
    width: 100%;
    position: absolute;
}

Additional information provided:

console.log( $(this.parentNode).outerHeight(true) );
console.log( $(this.parentNode).height() );
or console.log( $(this.parentNode).attr('style') - returns the background;

console.log(this.parentElement) provides the data I am attempting to access.

I am trying to access this specific attribute!

Answer №1

.getHeight() retrieves the height of an element

.getInnerHeight() calculates the height of an element including top and bottom padding

.getOuterHeight(true) is the recommended method as it returns the total height of an element including padding, border, and margin if set to true

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

Loading AJAX content using Selenium Webdriver as you scroll

Currently, I am utilizing Selenium WebDriver to retrieve the content from a website that unfortunately lacks an API. The site employs AJAX for dynamically loading content as the user scrolls through the page. In order to access this content, my approach in ...

Encountered a problem while assigning a function to a variable

I'm currently working with a function that retrieves images based on a search query. Here's the code: function getImage(query){ var serach_title = query.replace(/\ /g, '+'); var imgUrl = "https://ajax.googleapis.com/ajax/s ...

Mistake in closing the component by the parent is causing an issue with Vuetify's v-dialog functionality

Recently, I encountered a situation where a component contained a straightforward v-dialog to display a message to the user and a v-btn to close it. The sequence of events went as follows: The user clicked on the button that triggered the v-dialog's ...

Tips for resolving the issue of "Text stays in original position while image changes in the background when hovering over the text."

I'm currently working on a website and I have a question regarding how to make text stay in position while hovering over it (inside a span), and at the same time, display an image in the background that allows the text to overlay it. HTML: <ht ...

What is the best way to receive a notification when a user chooses any option in a Material UI Autocomplete React component?

My dilemma involves using an autocomplete feature that doesn't behave as expected. I am looking to detect when an option is selected, regardless of whether it's the same as the last selection. The onChange event I'm using only triggers if th ...

Retrieve the Data from Input Fields with Matching Classes and Transmit to a Script Using AJAX Request

I am working on a form that includes multiple input fields: <input type="text" class="date" name="date[]" onkeyup="showHint()" /> <input type="text" class="date" name="date[]" onkeyup="showHint()" /> <input type="text" class="date" name="da ...

Angular 4 showcases the information stored within this dataset

The data returned from an API to my Angular 4 application is not to my liking. Here is an example of the JSON, where I am only interested in the coin and its price: Goal is to display this data on the page: Coin Price BTC $4,281.28 ETH $294.62 ...

What is the best way to position divs on opposite ends around another div?

I have experimented with this scenario so far, http://jsfiddle.net/BXSJe/4/ My goal is to position two divs on the left and right sides within another div, using float:left and float:right resulted in them appearing on separate lines. What I envision is ...

By simply clicking a button, you can input a value into a field without the need for the page to refresh

Can someone please help me figure out how to insert a specific value into an input field without refreshing the page? I have tried the following code but it doesn't seem to work. Basically, when I click the button, I want the value "1234567" to be aut ...

When attempting to click the "New" button in a lightning datatable to add a new row, an error

Having trouble adding a new row when clicking the New Button in a Lightning Data table. I've created a lightning-button in HTML and called the method in JavaScript. However, when I click the New button, I'm getting an error message saying Undefin ...

Adjust the log level on winston in real-time

Is there a way to update the log level dynamically in winston and have it reflect across multiple files? I am facing an issue where changing the logger level in index.js does not affect readfile.js. How can I resolve this? Below is the code snippet: win ...

Are there any solutions to refresh a page by clicking a button in next.js?

I am currently learning how to work with next.js and I'm facing an issue where I need to reload my page to make a new API request. As a beginner, I'm not sure how to achieve this. I've tried a few methods but none of them seem to work. Below ...

Highlighted Answer: Choosing between two options in the quiz

I am currently developing an employability quiz for my university project. Each question offers a choice between Yes and No answers. If the user selects the Yes answer, it will be highlighted in green and display the correct answer below. However, if the ...

Rails 4 does not properly handle the execution of Ajax responses

Currently, I am incorporating ajax functionality within my Rails application. Within the JavaScript file of my application, the following code snippet is present: $('#request_name').on('focusout', function () { var clientName ...

What is the best way to send symbols to php for updating?

Is there a way to successfully submit special characters to PHP and have it update my database tables without any issues? I've noticed that when I try using symbols like ('!@#$%^&*()_+=),, the database table doesn't get updated. Any assi ...

Attempting to employ the HTML5 file picker feature within the AppMaker platform

Hey there, I'm currently working on integrating the HTML5 file picker into my AppMaker app. (Since my app needs to run as the developer, I can't use Drive Picker). I've been able to display the file picker in an HTML widget using the follow ...

Navigating to various files using Ajax is a breeze with these simple steps

function disableHandler() { if (confirm("Are you sure you wish to Disable Penalty Marks?" + "\n" + "(You cannot change your option once you have confirmed)" + "\n")) { $.when($.ajax({ url: "penaltyinsert.php", ...

Modify the URL parameter when a button is clicked

I want to apologize in advance for not providing more information. If the limited info is not enough, I will remove the question. There's a script that creates a search engine based on another dynamically generated script which is complex and beyond ...

JustGage error: Unable to locate element with ID 0 in AngularJS

I developed a custom directive for the JustGage plugin, here is how it looks: function justGage() { return { restrict: 'E', replace: true, scope: { universalId: '@', ...

The hamburger menu image is not appearing when using the CSS background-image property

The burger menu image I have as a background image is not displaying in my navigation bar or on the page. I set it to appear when the page is responsive (max-width: 480px), but it still doesn't show. I even tried copying the code to my main CSS above ...