Responsive images with aspect ratio without any media queries

Creating responsive images with aspect ratio without using media queries can be achieved using a combination of CSS Flexbox and the aspect-ratio property. Here’s how you can do it:

Step #1:- Html Page

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Images with Aspect Ratio</title>
<style>
  .image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  .image-container img {
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 16 / 9; /* Change the aspect ratio as needed */
  }
</style>
</head>
<body>
  <div class="image-container">
    <img src="image.jpg" alt="Example Image">
  </div>
</body>
</html>

Output:-

Output 2:-

Hopefully, It will help you …!!!

Related Posts

RobotOps and Robot Fleet Management: A Practical Guide

What happens when a robot stops working during a busy production shift? A technician arrives, checks the machine, searches for the problem, and tries to restore operations….

Read More

Site Reliability Engineering: Key Concepts, Tools, and Best Practices

Introduction Imagine your favorite video game crashes during a match. You feel annoyed because the game stopped working. Websites face this exact problem every single day. Millions…

Read More

The Future of Computer Operations: How Smart Systems Fix Problems

Every day, millions of people tap smartphone screens to navigate morning traffic, order groceries to their doorsteps, and transfer money between bank accounts in seconds. Behind every…

Read More

How DataOps Improves Alert Accuracy with AI Tools

Data pipelines run constantly to deliver numbers, reports, and dashboards. When something breaks, monitoring systems send alerts to data engineers. But when these notifications ring every ten…

Read More

Core Engineering Skills Needed to Master Data Pipeline Automation Systems

Introduction Imagine building a giant LEGO castle, but someone keeps swapping out your plastic bricks for blocks of melting ice. That is what working with raw digital…

Read More

Continuous Data Validation in DataOps: The Complete Architecture Guide

Continuous data validation is the systematic practice of asserting data correctness, schema consistency, and distribution integrity across every state boundary of an enterprise data pipeline. In DataOps,…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x