KandZ – Tuts

We like to help…!

CSS 13 ๐Ÿ’ป image orientation, image rendering, object fit and object position properties

image-orientation โ†’ specifies the orientation of an image
values โ†’ none, from-image and global values
example โ†’ sets the orientation from the image EXIF data
image-rendering โ†’ controls how browsers render images
values โ†’ auto, crisp-edges, pixelated and global values
example 1 โ†’ this value forces the image to be rendered with pixelated edges
example 2 โ†’ ensures that the image has sharp edges

object-fit โ†’ specifies how the content of an image and video will be resized to fit its container
values โ†’ contain, fill, cover, none, scale-down
it has no effect to other replaced elements such as iframe, embed and fencedframe
example 1 โ†’ scales the image to fit within the container without distorting its aspect ratio
example 2 โ†’ scales and crops the image to fill the entire container while maintaining its aspect ratio
fill โ†’ fills its container and even changes the aspect ratio
none โ†’ not resized
scale-down โ†’ like none or contain, to the smallest version

object-position โ†’ sets the alignment of an image, video element within its container
values โ†’ top, bottom, left, rights, center, percentage, length values and...
offset values like bottom 20px right 30px
example 1 โ†’ positions the image's top left corner at the top left of the container
example 2 โ†’ this centers the image both horizontally and vertically within the container
example 3 โ†’ positions the image's bottom right corner at the bottom right of the container

13 – image-orientation, object-fit and object-position properties

<img class=".from-image" src="oriole.jpg" alt="Orientation taken from the image" />
<img src="oriole.jpg" alt="none" />
<img class="image-pixelated" src="your-image.jpg" alt="Your Image">
<img class="image-crisp" src="your-image.jpg" alt="Your Image">
<p><span class="image-contain"><img src="path/to/your/image.jpg" alt="Example Image 1" class="contain"></span></p>
<p><span class="image-cover"><img src="path/to/another/image.jpg" alt="Example Image 2" class="cover"></span></p>

<p class="image-position"><img src="path/to/your/image.jpg" alt="Example Image 1" class="top-left"></p>
<p class="image-position"><img src="path/to/another/image.jpg" alt="Example Image 2" class="center-center"></p>
<p class="image-position"><img src="path/to/yet/another/image.jpg" alt="Example Image 3" class="bottom-right"></p>
img{
    width: 100px;
}

.from-image {
  image-orientation: from-image; orientation from image
}

.image-pixelated {
    width: 100px;
    height: 100px;
    border: 1px solid #ddd;
    margin-bottom: 20px;
    image-rendering: pixelated; 
}

 .image-crisp {
    width: 100px;
    height: 100px;
    border: 1px solid #ddd;
    margin-bottom: 20px;
    image-rendering: crisp-edges; 
}
.image-contain {
    width: 200px;
    height: 150px;
    border: 1px solid #ddd;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-cover {
    width: 200px;
    height: 150px;
    border: 1px solid #ddd;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

img.contain {
    object-fit: contain; 
    max-width: 100%;
    max-height: 100%;
}

img.cover {
    object-fit: cover; 
    max-width: 100%;
    max-height: 100%;
}

.image-position {
        width: 200px;
        height: 150px;
        border: 1px solid #ddd;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    img.top-left {
        object-fit: cover;
        max-width: 100%;
        max-height: 100%;
        object-position: top left; 
    }

    img.center-center {
        object-fit: cover;
        max-width: 100%;
        max-height: 100%;
        object-position: center; 
    }

    img.bottom-right {
        object-fit: cover;
        max-width: 100%;
        max-height: 100%;
        object-position: bottom right; 
    }

Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!

Leave a Reply