When the window is resized, the nested div parent and child are overlapping

Is there a way to fix the issue of the content div overlapping the logo div when resizing the browser window? I would like the logo to resize along with the window.

@charset "utf-8";
/* CSS Document */

html, body {
    background-color:#ffffff;
    margin:0;
    padding:0;
    height:100%;
    width:100%;
}

#content {
    height:74%;
    background-color:#7d6961;
    width:100%;
    position:relative;
    top: 10%;
}

#logo {
    background-image:url(logo.png);
    background-repeat:no-repeat;
    position:absolute;
    left: 9%;
    top: 5%;
    right: 2%;
    bottom: 21%;
    width: 77%;
    height: 65%;
}

Answer №1

To adjust image size dynamically, utilize the resize-callback function within the window-DOM Object.

$(window).resize(function () {
    var _width = $(window).width(),
        _height = $(window).height();

    console.log('width: ' + _width);
    console.log('height: ' + _height );
});​

For a practical example of implementation (such as placing a logo inside an img-Tag for full visibility), refer to this jsfiddle: http://jsfiddle.net/qY3kM/

It is not feasible to perform dynamic resizing of images using only CSS (as far as I know... perhaps through css-expressions, but they are considered inefficient and shouldn't be relied upon.). While there are jquery plugins available for dynamic resizing, I have not personally used one and thus cannot provide a recommendation.

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

Consolidate radio group in Vuetify platform

I'm having trouble centering the v-radio-group. Here's my current setup: <v-container grid-list-md text-xs-center> <v-form ref="form"> <div v-if="question.question_type == 'YESNO' "> <v-radio-group ...

What is the best way to align the checkbox and label in a React form?

I've been struggling to align the labels next to the checkboxes on this form. I'm currently utilizing React with React-Hook-Form for validation and state management (you can find the code on GitHub: https://github.com/cipdv/ciprmt-mern/blob/main/ ...

Eliminate the lower boundary of a divisional table

I'm having an issue with displaying images in a div table. Each image has a border at the bottom, which is around 2-5 pixels wide. Unfortunately, as a new user, I am unable to send any images. My main goal is to remove this unwanted border from the ...

Applying CSS classes to a custom AngularJS directive: A step-by-step guide

Need to have a CSS class called tab for the nav HTML element, which will be used as a directive: <nav tab></nav> The expected interpretation is: <nav class="tab"> <a></a> <a></a> <a></a> ...

Jquery solution for toggling multiple Divs individually

I'm currently working on a small application that has both a sidebar menu and a header menu. My goal is to have all items in these menus toggle the visibility of content in one main window or page. When a button is clicked, I want it to show the corre ...

Using Bootstrap 3 to create a carousel with a seamless fading transition as the background

I want to utilize Bootstrap Carousel as the background for my website. I've successfully incorporated a standard carousel as the background, but I'm encountering difficulties with making fade transitions. Here is my current implementation: HTML: ...

Creating interactive JavaScript elements that can be moved around within a container

I recently faced a challenge while attempting to make draggable elements within a div. The issue arose when I realized that I couldn't figure out how to drag each element individually without affecting the others. My current code only allows for handl ...

Looking to create a row-column-row layout using CSS flexbox techniques

` I am trying to create a unique row-column-row layout using CSS flexbox. Below is the code snippet I have: * { padding: 0; margin: 0; box-sizing: border-box; } .container { display: flex; flex-wrap: wrap; gap: 0.2%; } .box { color: whit ...

Is there a way to automatically redirect the main html page to a different html page upon logging in?

I have created a main page in HTML with a login box that displays a message saying "Login successful" or "Login failed" based on whether the password entered is 8 characters or more. The validation function for this works correctly, but after successfully ...

Python script utilizing Selenium is returning an empty string when trying to extract data from

When I try to retrieve the value from a dynamically loading table by clicking on the TD element, it works fine. However, when I attempt to fetch the text from the same TD element, it returns an empty string despite trying XPATH and CSS Selector methods. H ...

Is it possible to send information via the URL while using jQuery Mobile?

My mobile application utilizes an in-app browser to send information, such as deviceID, to my server via a URL. For instance, the browser opens a web-page (jquery Mobile): www.myserver.com/doWork.html#deviceID Within the doWork.html file on the server si ...

Utilize Python and BeautifulSoup for parsing HTML with multiple tags and classes

I am currently attempting to navigate through a complex HTML structure. Here is the snippet of the HTML code: <div class="example one"> <ol class="example two"> <li class="example three"> My object ...

The image appears uniquely sized and positioned on every screen it is viewed on

After reviewing the previously answered topics on the site, I couldn't seem to make the necessary adjustments. Despite setting the size and location in the css file, the large image remains centered and fitting for the screen. The "imaged1" class seem ...

Dynamically add Select2 with a specific class name: tips and tricks

I need help adding a new row with a select2 instance using a class name. The new row is created with the select dropdown, but I am unable to click on it for some reason. var maxGroup = 10; //add more fields group $(".addMor ...

"Google Chrome v84 does not render elements with zero height, line-height, and display: flex correctly

In Google Chrome v84, there seems to be an issue with line-height and display: flex (Chrome v83 and FireFox are not affected). The height of the element is not always enforced properly. <div class="outer-wrapper"> <div class="wrap ...

Even after applying the CSS property "resize:none" to my HTML textarea, I still find it to be adjustable in size when viewed in the Opera browser

I'm currently working on customizing my HTML page and I want to ensure that all text inputs are consistent in size. I attempted to use the text-area selector in CSS, but it didn't seem to work correctly in Opera. The resize handle disappeared in ...

Customizing CSS based on URL or parent-child relationship in WordPress

I'm having trouble finding a solution for what seems like a simple issue... Currently, my header has a border-bottom and I'd like to change the color of this border based on the section the user is in. For example, consider these parent pages: ...

What is the method for individually extracting values from HTML using class li?

Is there a way to extract each value from the HTML within the li class separately? I have tried various methods but none have been successful. Can anyone provide a solution? Here is my JavaScript code: $(document).ready(function() { $(".list-grou ...

JavaScript validation for basic "select" isn't functioning as expected

I need assistance with my simple "select" validation using JavaScript. The issue I am facing is that when validating the "select" element, it does not display the select options to users after a validation error occurs. "The select option is not re-enabl ...

Finding the label that is linked to the current DIV or textarea by its "for" property

I am working on a project that involves two elements - a textarea and a div. Each element has a label attached to it using the "for" attribute in HTML. <textarea id="txta_1" class="txta" cols="40" rows="3" onkeyup ...