CSS - table and image height issue

Hi

I have a table, and one of the columns displays a preview to a document. The preview is about 1000px in height, but I want the row to be limited to 100px in height, and the user can scroll to see the rest of the preview, or just click on the link to open the document in Word Online.

With the samples below, the row height keeps adjusting to fit the whole image.

Any help is greatly appreciated.

Here is a link to my sample on w3schools

Here is the HTML I am using:
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}

ex1 {
    max-height: 50px;
    overflow: auto;
}
</style>
</head>
<body>

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr >
    <td class="ex1"><img src="https://www.clicktorelease.com/tmp/google-svg/image.svg" height="250px"/></td>
    <td >$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>


</body>
</html>

Open in new window

LVL 1
maaknplanSenior DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan LouwerensSoftware EngineerCommented:
Try adding a div to the table cell, and style on that:

    <td class="ex1"><div><img src="https://www.clicktorelease.com/tmp/google-svg/image.svg" height="250px"/></div></td>

Open in new window


.ex1 div {
    max-height: 50px;
    overflow: auto;
}

Open in new window


https://www.w3schools.com/code/tryit.asp?filename=FP838PTRTCJV
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maaknplanSenior DeveloperAuthor Commented:
Thanks Jan, your solution works great.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.