JavaScript Have div match image height with overflow without using javascript?

I have the code shown here: https://codepen.io/allen-houng/pen/ExYKYdq

and a gist here:

<div class="parent">
 <div class="imageWrapper">
  <img class="image" src="imageurl" />
  </div>
  <div class="textWrapper">
   ...lots of text
  </div>
</div>

the parent is a flexbox and the two children are flex children. is there anyway to have the textWrapper div match the height of the image while scrolling if content has exceeded height (without using javascript?)

Expected result: enter image description here

Actual result: enter image description here

Answer:1

First set for the .parent display: flex to make the column same height,

then set for the .textWrapper column overflow: auto; position: relative

add a .inner-text child element with position: absolute;

.parent {
    display: flex;
}

.textWrapper {
    position: relative;
    overflow: auto;
}

.textWrapper .inner-text{
    position: absolute;
}

here full example:

.parent {
    width: 620px;
    display: flex;
}

.imageWrapper {
    width: 100%;
    flex: 1;
}

.image {
    width: 100%;
    display: block;
    background:  linear-gradient(red, yellow, green);
    height: 205px;

}

.textWrapper {
    flex: 1;
    background: purple;
    color: white;
    position: relative;
    overflow: auto;
}

.inner-text {
    position: absolute;
}
<div class="parent">
    <div class="imageWrapper">
        <img class="image" />
    </div>
    <div class="textWrapper">
        <div class="inner-text">
            Fusce consequat. Nulla nisl. Nunc nisl. Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi,
            in porttitor pede justo eu massa. Donec dapibus. Duis at velit eu est congue elementum. Fusce consequat.
            Nulla nisl. Nunc nisl. Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor
            pede justo eu massa. Donec dapibus. Duis at velit eu est congue elementum. Fusce consequat. Nulla nisl. Nunc
            nisl. Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa.
            Donec dapibus. Duis at velit eu est congue elementum. Fusce consequat. Nulla nisl. Nunc nisl. Duis bibendum,
            felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa. Donec dapibus. Duis
            at velit eu est congue elementum. Fusce consequat. Nulla nisl. Nunc nisl. Duis bibendum, felis sed interdum
            venenatis, turpis enim blandit mi, in porttitor pede justo eu massa. Donec dapibus. Duis at velit eu est
            congue elementum. Fusce consequat. Nulla nisl. Nunc nisl. Duis bibendum, felis sed interdum venenatis,
            turpis enim blandit mi, in porttitor pede justo eu massa. Donec dapibus. Duis at velit eu est congue
            elementum.
        </div>
    </div>
</div>
Answer:2

You should use grid, it separates both at the same size, and the parent element will adjust depending of the child sizes. But then one of the child could have overflow: scroll, and the other not, so the parent will only adjust to the image.

.parent {
   display: grid;
   grid-template-columns: 1fr 1fr;
}

img {
   width: 100%;
}

.text-wrapper {
   overflow: scroll;
}

Also, if you have different images sizes, you can crop them all by putting this css style:

img {
   object-fit: cover;
   object-position: 50% 50%;
}

And then put parent style with the desired size:

.parent {
   height: 600px;
}
Answer:3

Here I am mapping financialTransactionDetail array and populating data. Values are coming fine. Now I have to get the sum of TransactionAmount, like the length of array is 3 there are 3 ...

Here I am mapping financialTransactionDetail array and populating data. Values are coming fine. Now I have to get the sum of TransactionAmount, like the length of array is 3 there are 3 ...

  1. find array element matlab
  2. find array element javascript
  3. find array element mongodb
  4. find array element in java
  5. find array element python
  6. find array element in another array javascript
  7. find array element in php
  8. find array element in array
  9. find array element by value php
  10. find array element js
  11. find array element in jquery
  12. find array element in c
  13. find array element typescript
  14. find array element index matlab
  15. find array element position javascript
  16. find array element position php
  17. find array element index python
  18. find array element vba
  19. find array element index java
  20. find array element lodash

At the moment when 'scroll' is at the very bottom, the function getUsers () is called. How to set the scroll so that it doesn't reach the end of the slider, and the getUsers () function is called. ...

At the moment when 'scroll' is at the very bottom, the function getUsers () is called. How to set the scroll so that it doesn't reach the end of the slider, and the getUsers () function is called. ...

I have a div class ".square", i want to show an alert if there is a mouse clicking outside of the div element, i can't find something similar according to mouse event on this website w3schools. ( i ...

I have a div class ".square", i want to show an alert if there is a mouse clicking outside of the div element, i can't find something similar according to mouse event on this website w3schools. ( i ...

I have this code, where I run parseString()to extract some information from an xml file function parseTime(){ var parser = new xml2js.Parser(); var data = fs.readFileSync('C:\\Temp\\tasks\\acis\\110-...

I have this code, where I run parseString()to extract some information from an xml file function parseTime(){ var parser = new xml2js.Parser(); var data = fs.readFileSync('C:\\Temp\\tasks\\acis\\110-...