What is the best way to resize my images without distorting their appearance?

I am currently facing an issue with utilizing images in my project. I aim for them to resemble the first two pictures. However, when I attempt to adjust the image height using CSS, the result ends up looking unappealing. Is there a method for the images to resize automatically without overlapping, similar to what occurred with the third image?

CSS :

.product-image-wrapper{
 border:1px solid #F7F7F5;
 overflow: hidden;
 margin-bottom:30px;
 }

.single-products {
 position: relative;
 }

.new, .sale {
 position: absolute;
 top: 0;
 right: 0;
 }

.productinfo h2{
 color: #FE980F;
 font-family: 'Roboto', sans-serif;
 font-size: 24px;
 font-weight: 700;
 }
.product-overlay h2{
 color: #fff;
 font-family: 'Roboto', sans-serif;
 font-size: 24px;
 font-weight: 700;
 }


.productinfo p{
 font-family: 'Roboto', sans-serif;
 font-size: 14px;
 font-weight: 400;
 color: #696763;
 }

.productinfo img{
 width: 100%;
 }

.productinfo{
position:relative;
}

.product-overlay {
 background:#FE980F;
 top: 0;
 display: none;
 height: 0;
 position: absolute;
 transition: height 500ms ease 0s;
 width: 100%;
 display: block;
 opacity:;
 }

.single-products:hover .product-overlay {
display:block;
height:100%;
}


.product-overlay .overlay-content {
bottom: 0;
position: absolute;
bottom: 0;
text-align: center;
width: 100%;
}

.product-overlay .add-to-cart {
background:#fff;
border: 0 none;
border-radius: 0;
color: #FE980F;
font-family: 'Roboto', sans-serif;
font-size: 15px;
margin-bottom: 25px;
}

.product-overlay .add-to-cart:hover {
background:#fff;
color: #FE980F;
}


.product-overlay p{
font-family: 'Roboto', sans-serif;
font-size: 14px;
font-weight: 400;
color: #fff;
}

JSFiddle

This is how my actual page appears:

Answer №1

Adjusting the image to the proper dimensions is likely your most effective solution. Another option could involve creating a container div around the third image with precise measurements and applying overflow:hidden. This method essentially trims the image. Personally, manually adjusting the cropping of the image would provide more control over what is displayed. In order to prevent distortion, handling cropping in some form is necessary.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for maintaining the integrity of blank space within a text node?

When intercepting a paste event and cleaning HTML off of the content using textNodes, I am faced with an issue where all white space is reduced to a single space and new lines are disregarded. For example, pasting: "hello world !" ends up being "h ...

Ways to organize information based on the date

Is there a way to organize data from an API in chronological order? Here is an example of how it should be displayed: <table> <tr> <th>2017-02-17</th> </tr> <tr> <td>some date</td&g ...

Animate movement in CSS3 by utilizing the CSS grid class to handle x and y coordinates

Currently, I have organized my tile elements in a grid using absolute positioning with classes like .row1, .col1... .row6, .col6. If I want to move a tile from .row6, .col6 to .row2, col2 using CSS3 GPU accelerated transitions and transformations Can you ...

"Utilizing the owl carousel to dynamically adjust the height of various images and fill

Currently, I am using the latest version of the owl carousel and encountering a small issue. The problem lies in the fact that I have 3 images with varying sizes. The main div, labeled as "mydiv," is required to have a width of 614px. However, upon closer ...

Wrapping text in DataTables

I am experiencing an issue with the cell content below: <td style="max-width:200px;" class="sorting_1"> <i class="fa fa-circle text-success"></i> <span style="width: 200px;"> Публикация: "The Myth of Ponce de León an ...

Set a variable equal to the innerHTML

Although I am not very familiar with JavaScript, I am looking to generate HTML table TD elements dynamically using JavaScript. Unfortunately, the code I have written is not functioning correctly. <script type="text/javascript"> function changed(num) ...

Hide React micro animations on component using display:none

Is there a way to make this component appear on button click with a smooth ease-in expand or popout animation? I'd like the transition to be smoother rather than it just appearing suddenly. const CardExample = () => { const [show, setShow] = use ...

I'm currently navigating through various sections of HTML, making sure to keep track of which

I am faced with a situation where I have 2 HTML sections that both share the same ID. Unfortunately, this is out of my control as it is being generated by a third-party CMS. Currently, I have a simple code running to determine how many html sections there ...

An error occurs when attempting to echo empty values from an array due to the "undefined index" issue being

Answering this question seems quite straightforward. Let me outline what needs to be done. I possess an array $polarity_array The array holds values in the form of HTML tags that present images. However, there are some empty values in the array because ...

Is the material input label malfunctioning?

When I input data into the model, it appears like this. https://i.sstatic.net/WG12e.png After clicking on the input field, it displays like this. https://i.sstatic.net/3ZVIv.png This is in Blade (model-edit-users). <div class="md-form col-md"> ...

The ng-tagsInput feature seems to be malfunctioning

JavaScript var app = angular.module('plunker', ['ngTagsInput']); //'ngTagsInput' app.controller('MainCtrl', function($scope, $http) { $scope.tags = []; $scope.loadTags = function(query) { return $http.get( ...

Fuzzy text in drop-down box on Chrome, clear on Firefox

I've encountered an issue with a dropdown menu in Google Chrome where the content appears blurry, while it displays correctly in Firefox. The problem arises when the dropdown exceeds a certain height, and I've tried setting a max-height with over ...

Develop a file upload progress tracker using jQuery and AJAX

I have successfully implemented an AJAX upload feature that displays a progress bar and percentage completion. However, I would like to enhance the user experience by creating a separate progress bar for each file being uploaded. Is it possible to achieve ...

Execute action after changing background-position in JQuery

I am currently updating the background-position property of a div to gradually change its color from left to right. After completing the position transition, I am looking to trigger another action in JQuery to modify the fill of the #event_2 element: < ...

Divide document using PHP and create material

Looking for a way to split the content below into separate files and remove the placeholder tags? Also, want to extract the text inside the placeholder tags and save them in a new contents file. <div class='placeholder'>The First Chapter& ...

Modify the color of a particular character in a CSS text box when hovered over

I am facing a challenge in changing the color of two specific characters when hovering over them inside a textbox that is styled purely with CSS. As the content is created using only CSS, I am unable to use style tags to accomplish this and feel stuck. M ...

When mousing over a subitem of the Image menu, ensure that the Image menu

Is there a way to prevent the image menu from reverting back to its original image when hovering over its subitems? I have 5 navigation menu items, but only one has a dropdown. Whenever I hover on the subitems of About Us, the image for About Us changes ba ...

The slidedown feature is not functioning as initially planned

As a beginner in HTML, jQuery, and CSS, I am attempting to create a navigation bar that will trigger a jQuery slidedown effect when clicked. Unfortunately, my current code is not producing the desired outcome. Below is a snippet of what I have implemente ...

Is the overlap of viewport unit VW less than 100 vw per viewport?

So if I am correct, 1vw represents 1/100th of the width of a viewport, meaning there are 100vw across any given viewport. But here's an interesting scenario - when I have two divs each with a width of 25vw, one positioned 25vw from the right edge and ...

Ways to implement a 'Delete' feature in a PHP audio tag player

"I successfully retrieved the name of the uploaded file and am able to play it in my browser. How can I incorporate a delete function for each user-uploaded song?" echo "<hr />"; echo "<h4>" . $name . "<br /><a href='#' titl ...