Crop Image To Ratio

2 years 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

Search Results

< 1 min read

Search Result Custom Order

To add this code, go to Dashboard > Appearance > Theme File Editor and add one of these codes at

Read more

Header

< 1 min read

Header Padding: Conditional HTML

If you want to have conditional padding for your header, give your header the CSS class .mainheader and add an

Read more

Video

3 min read

YotuWP Plugin: Custom CSS

Go to Dashboard > Appearance > Customize and add this custom CSS. LIGHT MODE CSS DARK MODE CSS

Read more

Single Post

2 min read

Hiding “Previous Post” Navigation in Elementor with Custom CSS

Hi, there! I’ll share some quick tips on how to change the appearance of article navigation on your Elementor website.

Read more

See How It Works

Create better websites, faster.

Download the Entire Library

Adaptative, neutrally designed components.

Customer Service

Focus Website

Today, December 4

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.