Crop Image To Ratio

12 months ago

< 1 min read

Posted by:

Focus

Subscribe to newsletter

By subscribing you agree to with our Privacy Policy.

Share

To crop image based on ratio, on Elementor’s Image Widget add this CSS:

16:9 Landscape CSS


selector {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
    overflow: hidden;
}

selector img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 56.25%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
    object-position: center;
}



9:16 Portrait CSS

selector {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 177.77%; /* (9 / 16) * 100% */
    overflow: hidden;
}

selector img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 56.25%; /* (16 / 9) * 100% */
    min-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
    object-position: center;
}

Read more

Container

< 1 min read

Make Container Scrollable

Add this on the column’s custom CSS panel. Adjust the ‘max-height’ to your needs.

Read more

PHP

< 1 min read

Maximize PHP Settings Manually on Plesk

Go to ‘File Manager’, edit .htaccess, and add this code after # END WordPress

Read more

Video

< 1 min read

How to Make Play Icon on Image Overlay Smaller (Elementor Video Playlist Widget)

If you activate the image overlay, there is an option to show play icon. And the default play icon for

Read more

Text Widget

2 min read

Perfecting WordPress Text Content Formatting

If you want to have slightly better but very satisfying content formatting for those who understand content formatting, use the

Read more

See How It Works

Create better websites, faster.

Download the Entire Library

Adaptative, neutrally designed components.

Customer Service

Focus Website

Today, February 23

Hi, there 👋

How can I help you?

Start Chat with:

We use cookie to improve your experience on our site. By using our site you consent cookies.