Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the height of an children element

Hello i will set the height for my div into state.

i tried get the whole height by get window.innerHeightthis worked fine but i cant access the children of my div, i also try document.getElementById('masonryParent') i get also the right result but how i can access the div bellow. Any suggestions?

 this.setState({
      width: window.innerWidth, height: window.innerHeight
    });

enter image description here

like image 499
Alex Avatar asked Jun 12 '17 09:06

Alex


People also ask

How do you find the elements of children?

To get the children of an element, you use the childNodes property of the element. How it works: First, select the element whose id is container using the querySelector() method. Then, use the childNodes property to get the children of the container elements.

How do I get the height of an element in CSS?

Unfortunately, it is not possible to "get" the height of an element via CSS because CSS is not a language that returns any sort of data other than rules for the browser to adjust its styling. Your resolution can be achieved with jQuery, or alternatively, you can fake it with CSS3's transform:translateY(); rule.

How do you find the height of an element in HTML?

The HTMLElement. offsetHeight read-only property returns the height of an element, including vertical padding and borders, as an integer. Typically, offsetHeight is a measurement in pixels of the element's CSS height, including any borders, padding, and horizontal scrollbars (if rendered).

How do you find the content height?

clientHeight() It returns the height of the displayed content from the element (including vertical padding but not border or margin or scrollbar). It always returns an integer value in pixels. If element is hidden, then 0 is returned.


2 Answers

Try this

document.getElementById('masonryParent').children[0].style.height
like image 174
guest Avatar answered Oct 04 '22 06:10

guest


If you are using jquery you can you this :

$('.masonryParent div').style.height

like image 40
Ekta Aggarwal Avatar answered Oct 04 '22 05:10

Ekta Aggarwal