Hello i will set the height for my div into state.
i tried get the whole height by get window.innerHeight
this 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
});
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.
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.
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).
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.
Try this
document.getElementById('masonryParent').children[0].style.height
If you are using jquery you can you this :
$('.masonryParent div').style.height
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With