The initial div sibling is utilized as the backdrop for the subsequent dynamic div

Exploring HTML Markup,

    <div class="blurredBackground"></div>
    <div class="content">
       Hello! This content is always changing dynamically.<br>
       If the height of the second div increases, 
       I need the first div's height to increase accordingly.
    </div>

I am looking for a solution where the first div's height will adjust automatically when the second div's height changes due to dynamic content.

Currently, I have successfully stacked one div on top of another,

.content {
    width: 70%;
    height: auto;
    border:1px solid;
    position: absolute;
    z-index:10;
    background-color: white;
}

.blurredBackground {
    width:70%;
    height:70%;
    background-color: red;
    z-index:0;
    border:1px solid;
    position:absolute;
    -webkit-filter: blur(2px);
}

Is there a CSS solution to this issue? I have experimented with this approach > http://jsfiddle.net/hsinghbisht/nLj5dqay/2/

Your assistance is greatly appreciated!

Thank you in advance.

Answer №1

While this may not directly address the initial query, have you considered what you intend to achieve by aligning the second blurred div with the first at the same height?

If your goal is to create a stylish red blur effect in the background, you can easily accomplish this using the box-shadow property. Simply apply it to the .content class for similar results.

box-shadow: 0px 0px 4px 0px red;

However, if your heart is set on having a separate red blurred div element, standard CSS alone won't cut it. In that case, you'll have to incorporate JavaScript to dynamically match the styling of one element with another.

For instance:

window.onload = () => 
{
  const firstDiv = document.querySelector('.blurredBackground');
  const secondDiv = document.querySelector('.content');

  firstDiv.style.height = `${secondDiv.offsetHeight}px`;
}

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

Distinguishing CSS Variances on ASP.Net Site with Android 4+

I am encountering an issue with my current ASP.Net Mobile Website design. It is rendering correctly on android phones pre 4, iPhones, and Blackberries. This problem requires a bit of setup to explain... CSS tr { color: #00ff00; } #MasterBackButton { ...

Is there a way to include all images from a local/server directory into an array and then utilize that array variable in a different file?

I'm currently using Netbeans version 8.0.1 with PHP version 5.3 Here is a PHP file example: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/199 ...

Send an API call for every item in a given list

There is a function that I am working with: updateCustomers = (input) => { //let urls = input; let urls = [{ name: "localhost:8081", url: "http://localhost:8081" }, { name: "localhost:8082", url: "http://localhost:8081" }, { ...

The jQuery .click() function is not triggering when clicked

$("#backButton-1").click(function() { $("#form-2").empty(); $("#form-1").show(); }); I am experiencing trouble with this code snippet. The form-1 element is hidden, and the backButton-1 is created after the end of for ...

Achieving a cumulative running balance using Vue js for nested arrays

I am looking to calculate the running balance by subtracting AmountApplied from Amort. Here is the desired output: Line Amort Total Payment Running Balance 1 30250 10000 20250.00 30250 20250 0.00 ...

Angular: bypassSecurityTrustHtml sanitizer does not render the attribute (click)

I'm facing an issue where a button I rendered is not executing the alertWindow function when clicked. Can anyone help?: app.component.ts: import { Component, ElementRef, OnInit, ViewEncapsulation } from '@angular/core'; import ...

Error message: The function send() cannot be applied to the object received by request.post() in Node

As I embark on testing the functionalities of my node.js website using chai and mocha, I encountered an issue when running npm test. The error message displayed is: ' TypeError: request.post(...).send is not a function' Referencing the code sni ...

Unable to activate function when closing Vuetify v-alert

Is there a way to trigger a function when the Vuetify v-alert is closed? I have explored the documentation but haven't found any information on this specific functionality. In the codepen example, the dismissible attribute allows for closing the alert ...

Set the styling of a div element in the Angular template when the application is first initialized

I have a question about this specific div element: <div class="relative rounded overflow-clip border w-full" [style.aspect-ratio]="media.value.ratio"> <img fill priority [ngSrc]="media.value.src || ftaLogo" ...

Distinctive titles for JavaScript constructors/prototypes compared to classes

When working with JavaScript ES6, classes allow us to write code like this: class RectangularShape { constructor(height, width) { this.height = height; this.width = width; } getArea() { return this.height * this.width } static some ...

The CSS classes from Bootstrap are failing to function properly despite my best efforts in

I have been experiencing issues with the row and col classes in Bootstrap. <!DOCTYPE html> <html lang="en> <head> <meta charset="utf-8> <meta http-equiv="X-UA-Compatible" content="IE-edge> <meta name="viewport" content=" ...

Using AngularJS to load a custom JavaScript file within an ng-view

In my sample project, I have utilized Angular Js for the front-end. I have developed a template and implemented dynamic loading of views based on requirements. For this application, I am utilizing angular, jquery, and cusotm js. The structure of my templat ...

How can I make the Bootstrap tooltip only appear when clicked inside a Vue Component and disappear when hovered over?

I am having a challenge with Bootstrap ToolTip in my Vue component. I only want the notice to show when the button is clicked, not on hover as it currently behaves. I attempted using jQuery within the Vue component without success. Can someone please adv ...

What is the best way to remove an item from my online shopping cart using JavaScript?

I am currently developing an online store website. One issue I am facing is deleting items from the cart after a customer completes an order. Below is the array of cart items: const products = [ { id: '0', name: 'Nike Slim Shirt&ap ...

Manipulate and synchronize state in Vue using vuex from a separate component

Imagine this scenario: I have two files - App.vue and Home.vue. In App.vue, there is a navigation drawer component, and in Home.vue, there is a toolbar component. The issue arises when I try to toggle the state of the navigation drawer (true or false) from ...

Angular Table with Loading Bar

Hey there, here's the JSON data I have: [ { "name": "AAAAAA", "loading": "False", }, { "name": "BBBBBB", "loading": "45%", }, { "name": "CCCCCC", "loading": "12%", }, { ...

In JavaScript, I aim to decompress a zip file containing binary data by unzipping it

let resourceUrl = "http://localhost:9996/api/GetZipFile?id=1-1" ; $.ajax({ url: resourceUrl, type: 'GET', contentType: 'application/json', success: function (data) { if (data) { // The 'data&apos ...

Accessing individual .env files defined in the package.json

"begin:development": "set NODE_ENV=development&&nodemon ./bin/www", "begin:testing": "set NODE_ENV=testing&&nodemon ./bin/www", I am managing two unique .env files named dev.env and test.env. My goal is to utilize dev.env when running npm ...

The VUE project I'm working on seems to be having compatibility issues with the Bootstrap modal in V

I added bootstrap using npm and inserted the code from bootstrap into my project, but it's not functioning correctly. I've spent an hour trying to troubleshoot, but still no luck. Here is the code snippet: <template> <div> <! ...

Creating a new list by grouping elements from an existing list

I have successfully received data from my API in the following format: [ {grade: "Grade A", id: 1, ifsGrade: "A1XX", ifsType: "01XX", points: 22, type: "Type_1"}, {grade: "Grade B", id: 2, ifsGrade: &quo ...