Is there a way to store a class property as a variable using PostCSS?

Looking to store a dynamic property in a variable for use with calc().

There is a class with a height that changes dynamically.

.cuerpo-detalle {
  height: x;
}

The goal is to create a variable that captures the height property of the .cuerpodetalle class.

:root{
  cuerpoDetalle: .cuerpo-detalle.height;
}

This variable will be used as a dynamic measurement, multiplied by 2 for a footer expansion.

.footerxpand{
  height: calc(var(--cuerpoDetalle)*2);
}

Answer №1

To achieve a similar outcome using JavaScript, you can try the following approach...

For additional insights on calculating height dynamically in JavaScript, you may find this resource helpful.

const element = document.getElementById('body-content');
const height = element.offsetHeight;
document.documentElement.style.setProperty('--contentHeight', height + 'px');
:root {
  --contentHeight: auto;
}

article {
  height: calc(var(--contentHeight) * 1.5);
  background-color: #f1f1f1;
}

section {
  width: 80%;
  margin: 0 auto;
}
<div id="body-content">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ac imperdiet nulla. Aenean dapibus non nisl nec pellentesque.</p>
</div>

<article></article>

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

Encountering issues with loading JavaScript file in Reactjs

I'm currently working with Reactjs (Nextjs) and I am in the process of integrating the home page (index.js). I have various JavaScript files located in the "public" folder and I'm unsure of where to place them. Should I include these files in "_a ...

Admin template system for CodeIgniter

In order to give the Administrator the ability to customize the Admin Dashboard Layout and provide an option for them to upload their own layouts or "Premium" layouts, I need to implement a solution. I have considered one approach: Utilizing CSS (allowin ...

The scrolltop function is dysfunctional on CentOS operating systems

I'm currently working on implementing smooth scrolling functionality when a button is clicked. The feature works perfectly fine with a local Apache server and IE10+, but when the project is deployed on "CentOS", it doesn't work on the same browse ...

What is the best way to retrieve the array of triangles used to construct the 3D object?

I am trying to retrieve the array of triangles from the geometry object, but I am having trouble locating it. It seems that .faces in the object are not actually triangles. For example, when creating a cube, a face is structured like this: "faces": [{ ...

The Material-UI dialog is experiencing a flickering issue when incorporating Redux to manage the open

I am currently facing an issue with moving the open state of a material-ui dialog to redux in order to prevent it from closing during a rerender. However, I am encountering difficulties with the dialog's behavior when a rerender occurs. Even though th ...

The paragraph element is refusing to align with the next paragraph element on the following line

The issue I'm facing is that the paragraph element is not displaying on a separate line from the other paragraph element. body { margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; backgr ...

When using jQuery's .each method, only the final JavaScript object element is added to the divs

I have a unique set of dynamically-created divs, each containing a Title. When a div is clicked, a modal opens (which is cleared upon click), and the Title is displayed again in the modal. My goal is to add the category descriptions into these modals, but ...

Troubleshooting the integration of Text Mask Library with Vue - issue: no export named 'default' available

I was able to implement the vanilla JavaScript version: var maskedInputController = vanillaTextMask.maskInput({ inputElement: document.querySelector('.myInput'), mask: [/\d/, /\d/, '/', /\d/, /\d/, '/ ...

The use of "runat="server" in the HTML Head tag is preventing C# embedded code blocks from being converted to client-side code

After I included runat="server" in the head tag and added a CSS href with the value of <%= WebAppInstance %>, I noticed that the <%= WebAppInstance %> was not being converted to client-side code. To provide clarity on my question, please refer ...

Determine the value of an object by iterating through its keys

UPDATE: (for clarification) I currently have a table named modelCoa +----+----------+-------+--------------------+ | id | id_parent| code | name | +----+----------+-------+--------------------+ | 1 | 0 | 1 | asset ...

Is it possible to identify if an array is a polygon or multipolygon by examining its GeoJson data?

Recently, I came across an example illustrating a simple polygon. However, I wanted to display countries with complex polygons (multipolygons for some countries). Let me demonstrate the process: Example: "type": "Feature", "properties": { "Na ...

Manipulate and scale with jQuery

I am currently utilizing the jQueryUI library with its Draggable and Resizable functionalities to resize and drag a div element. However, I am encountering some unexpected behavior where the div jumps outside of its container upon resizing. How can I resol ...

The JMeter JSR223 Sampler and WebDriver Sampler do not support the Javascript language

I am currently working on integrating Selenium Webdriver Sampler with JMeter. Although I have been following tutorials, I have encountered an issue where the script language dropdown in the sampler screen does not include an option for JavaScript, prevent ...

"Troubleshooting the ineffectiveness of JavaScript's

(After reviewing all questions and answers related to this issue, I have not found a solution that works for me.) Here is the code snippet in question: var timeoutHandle; function showLoader(show) { if (show) { $('.loader').html(&a ...

Make the text stand out by highlighting it within a div using a striking blue

Currently, I am working with Angular2 and have incorporated a div element to display multiple lines of text. Positioned below the text is a button that, when clicked, should select the entirety of the text within the div (similar to selecting text manually ...

What are the steps to create a "load more" button that displays additional rows?

Struggling to get the code right for my webpage. I have a layout with 6 rows, each containing 3 columns filled with images. However, when I click on the "load more" button, nothing happens. I've attempted to modify the jQuery code from .slice(0, 3) t ...

Is it possible to navigate to the Next page using a different button instead of the pagination controls

Is it possible to navigate to the next page upon clicking a button labeled "Press me"? Here is the code snippet: <!doctype html> <html ng-app="plunker"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/an ...

"What is the best way to access the value of a useState variable in ReactJS on a global

Below is my reactJS code snippet - useEffect(()=>{ const getinterviewerDetails= async ()=>{ const data1 = await axios.get("http://localhost:8083/api/GetProduct") .then(response => { console.log("role is " ...

Responsive design involves ensuring that web elements such as divs are properly aligned

I am currently working on aligning 2 divs in a specific way that is responsive. I would like the right div to stack on top of the left div when the screen width reaches a certain point, as opposed to them both taking up 50% of the container's width. ...

Access and retrieve images directly from the output of an s3 bucket query

I've manually uploaded an image named userImage.png, but I'm unsure how to convert the incoming body of the result into an image. While I found some examples in this question[ how to retrieve image from s3 with nodejs ], I'm not sure how to ...