I am looking to create a two-column list that consists of an image on the left and a headline and text on the right. The images have a CSS scale transformation set on onMouseEnter in ReactJS code.
The issue arises when using float:left for the images to align them with the text, causing the layout to break. Adding overflow:auto to the <li>
element results in the image zoom-in animation not functioning properly, as the image gets sliced by the box boundaries of <li>
.
What is the optimal way to set the layout so that the <li>
elements stay separate and the <img>
elements display correctly on the left without being sliced during scaling?
Here is an image of the list:
https://i.sstatic.net/n3K33.png
And here is a list with a zoomed-in image, where the image is clipped by the box boundaries:
https://i.sstatic.net/XsIfY.png
li {
overflow: auto;
}
/* sets transition to transform and defines the length */
li img {
padding: 0 20px 0 20px;
width: 150px;
transition: transform 0.4s;
float: left;
}
/* describes the transformation itself */
li img:hover {
transform: scale(1.8);
}
li:hover {
background: papayawhip;
cursor: default;
}
<ul>
<li>
<img src="https://www.forexsrovnavac.cz/assets/img/turecka-lira-euro-dolar-kurzy.png" />
<div className="list-text">
<h3>Headline</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</>
</div>
</li>
<li>
<img src="https://www.forexsrovnavac.cz/assets/img/turecka-lira-euro-dolar-kurzy.png" />
<div className="list-text">
<h3>Headline</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</>
</div>
</li>