Improperly formatted image

I need help! I'm trying to center an image split into 6 equal parts on the page, but it's coming out squashed. I think the issue is that the images are appearing square instead of rectangles, but I can't figure out why.

Any assistance would be appreciated. Thank you!

I've provided the link below: Link

HTML

<ul class="cards">
  <li class="cards__axis">
    <figure class="cards__front">
      <img src="image-link-here" alt="" />

    </figure>
    <figure class="cards__back">
      <img src="image-link-here" alt="" />
      <figcaption class="cards__description--back">
        <p>ABOUT</p>
      </figcaption>
    </figure>
  </li>
…

CSS

*,
*:before,
*:after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

body {
  background: #333;
  font-family: 'Georgia', sans-serif;
}
…

Answer №1

The issue here lies in the aspect ratio of the panels. By setting the height to 100%, the width remains unaffected, causing the ratio to be distorted. To visualize this, try removing the height:100% from one of the .cards__back image panels and you'll notice it no longer appears "squished".

Keep in mind that the height is determined by the width of the parent element.

To preserve the aspect ratio, there are several methods available that I won't delve into now due to time constraints. However, one approach involves setting the height of a panel to zero and then adjusting the padding-bottom to a certain percentage of the height until the desired outcome is achieved.

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

Trouble with using .className for form validation

The .className is not applying the formValidation class on getWeight.length < 1 and getHeight.length < 1. I am stuck trying to figure out why this is happening after reviewing the code extensively. Any thoughts on what could be causing this issue? Y ...

Firefox failing to display CSS files on web pages

My project is deployed on IIS 7.5 and when trying to access it from a different machine using Firefox, all files are rendered except for the CSS files (although they work fine in IE). I have checked that the MIME type for .css files is correctly set up in ...

What is the best method for retrieving the entire row data based on the maximum value in a column?

function findMaxValue() { var highestValue = Math.max.apply(Math, $('.sira').map(function() { return $(this).text() })) alert(highestValue); } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"& ...

Next.js fails to update the user interface (UI) when there is a change in

In my latest Next.js project, I am working on a feature that involves looping through an array of amenities. Each amenity is displayed in a div element that, when clicked, toggles the active property. The logic behind this functionality is handled by the ...

The overflow property is set to scroll in jQuery, causing continuous scrolling until reaching a certain point, at which it

Continuously adding new chat messages will show the latest one, but eventually it stops scrolling down automatically. How do I resolve this issue? Thank you. http://jsfiddle.net/VMcsU/ $("#button1").click(function(){ $("<div>").html("text").app ...

Display line numbers in HTML/CSS cellsorIncor

Attempting to include row numbers in HTML/CSS. Below is the HTML code with React populating the rows: <table className="table table-striped"> <thead> <tr> {/*<th>ID</th>*/} ...

Receiving a 502 Bad Gateway error when attempting to request a CSS file via HTTPS

After recently adding SSL to some pages on my website, I encountered an issue when trying to call a secured web page <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="https:/ ...

Tips for showcasing additional choices within a SELECT element while incorporating floating labels and adjusting the size

I'm struggling to make a floating label work smoothly with an HTML select that has a size="5" attribute using Bootstrap 5.3.x. It seems like it's not possible without some hacks or missing information from the Bootstrap documentation. According ...

Enhancing your JQuery Select2 plugin by incorporating a Checkbox feature

I am currently utilizing the jQuery select2 plugin to enable multiple selections. My goal is to incorporate a checkbox for each selectable option. Depending on whether the checkbox is checked or unchecked, the dropdown option should be selected accordingl ...

Ways to correct the issue of multiple <div>s overlapping each other after being rotated by 90 degrees

Can someone assist me with rotating multiple divs without them overlapping? Below is a simplified version of my code: <div> <div class="rect"></div> <div class="rect"></div> <div class="rect"></div> & ...

inserting various values from a web form

I have a form containing a table with three columns: Roll_No, Name, and Marks. The Roll_no and Name are fetched from the database, and the teacher only needs to enter the marks for each student. However, I am facing an issue where only the last entered val ...

Menu elements should display a responsive behavior where on mobile devices, only the icon is shown instead of the word "menu"

Due to the length of our company logo, we need a way to hide certain letters in the Menu and Basket sections, while still displaying the icons. Wrapping the names in span tags and using visibility:hidden; works but leaves empty space visible on the right s ...

Shifting text upwards within a document

I'm struggling with CSS and bootstrap as I have limited knowledge in this area. I have multiple divs on a page that I want to align based on our old website design. The problem I'm facing is that one div is larger on the right, causing a lot of ...

Determine the number of inputs within a div and increment each one by +1 using jQuery

I am currently working on developing a slider and have successfully completed most parts of it, except for the challenge of counting input fields using jQuery and assigning an incremented number to each of them upon action completion. On my slide, I have ...

Display only the div on an iPad screen

Is there a way to show this DIV only on an iPad screen? I've looked around on Google for solutions, but none of them seem to work. It always ends up displaying on my computer as well. Is it possible to make it show only on an iPad screen? @media only ...

I'm looking for help on creating a three-column table using javascript/jquery. The table should display Product, Price, and Discount (which is calculated at 20%). Can anyone

Check out this code snippet. var items = ["Laptop", "Tablet", "Smartphone", "Headphones", "Camera"]; var costs = [599.99, 299.99, 799.99, 149.99, 499.99]; displayItems = ""; totalCost = 0; for (var j = 0; j < items.length; j++) { displayItems += " ...

Using AngularJS to apply custom css to a tag within a directive for creating a Bootstrap sticky footer

Currently, I am in the process of developing my very first AngularJS application with Bootstrap as the responsive framework. In order to achieve a sticky footer, I usually utilize jQuery to determine the outerHeight of the footer and then apply that value ...

What is the ideal location to store images that are referenced in a Django CSS file?

I recently downloaded a template from the internet which came with a base HTML file, images, and a CSS file. Now, I am attempting to incorporate all of this into my Django project. Unfortunately, my efforts have not been successful so far. The webpage is ...

AngularJS confirmation directive for deleting items

I am currently utilizing this directive for a confirmation prompt when deleting an app. However, regardless of whether I click cancel or yes, the app still gets deleted. <small class="btn" ng-click="delete_app(app.app_id)" ng-show="app.app_id" ng-con ...

Reducing the amount of text displayed on ion-text to a minimum

HTML: <ion-list *ngFor="let message of messages"> <ion-item lines="none" type="button" button="true"> <ion-grid> <ion-row> <ion-col class="message"> <ion-text> ...