MyBlogHelp– A Blog for Digital Marketing, Affiliate Marketing, Organic Lead Generation.
  • Home
  • About
  • Contact
  • Privacy
  • Sitemap
  • BLOG
  • AFFILIATE MARKETING
    • LeadsArk
  • MORE
    • MAKE MONEY
      • ONLINE BUSINESS
      • ADSENSE
      • AFFILIATE MARKETING
    • BLOGGING
      • SEO
      • BlogSpot
      • WORPRESS
      • GOOGLE
      • COMPUTER TIPS
    • WEB DESIGN
      • HTML
      • CSS
      • BOOTSTRAP
      • JAVASCRIPT
      • JQUERY
    • WEB DESIGN
      • HTML
      • CSS
      • BOOTSTRAP
      • JAVASCRIPT
      • JQUERY
    • WEB DEVELOPMENT
      • PHP
      • WORDPRESS
  • DOWNLOADS
    • Blogger Template
    • Wordpress Theme
    • PDF

Tuesday, May 21, 2019

How to use css object-fit property? CSS Tutorial 28

 MyBlogHelp     May 21, 2019     css     1 comment   

css object-fit property

 

  CSS object-fit Property

  1. Introduction to CSS object-fit property
  2. The syntax of CSS object-fit property
  3. Example of CSS object-fit property

Introduction to CSS object-fit Property

CSS object-fit property describes how to resize an image or video to fit it in its container. Some times this may be that there is very little space available in your webpage and you want to show an image. When you show the image in that space, the image shrinks because of less space and does not display properly. 

Or some times it may be that you have a lot of space available but the size of your image is very low. You want the image to cover the entire space but when you do so, the image gets very stretch and does not display properly.

Whatever the situation, you can resize image or video by the object-fit property. So that it can be properly displayed in the available space according to your requirement. For these values of this property, you have many options available.

Syntax of CSS object-fit Property

The general syntax of the CSS object-fit property has been given below.

object-fit: none | fill | contain | cover | scale-down; 

As you can see in the above syntax, the object-fit property can have five possible values. These are explained below.

  • none - Defining this value doesn't resize the object (image or video) in any way.
  • fill - By defining this value, the container is completely filled by the object, whether it has to stretch or shrink the image. This value does not preserve the object aspect ratio (real object clarity). That is, the image quality is not taken into account while stretching and shrinking the image.
  • contain - By defining this value, the size of the object is increased or decreased to fit in the container but the aspect ratio of the object is preserved.
  • cover - By defining this value, the container is completely filled by the object and the aspect ratio of the object is also preserved. But the object is clipped from the sides to fill the container.
  • scale-down - By using this value, the object is shrunk while preserving the aspect ratio of the object so that it can easily fit into the container.

Example of CSS object-fit Property

The CSS object-fit property has been explained by the below example.

<!DOCTYPE html>
<html>
<head>
 <title> CSS object-fit Property Example </title>
<style>
.scaleDown
{
   width: 600px;
   height: 200px;
   object-fit: scale-down;
}
</style>
</head>
<body>
<div>
<img class="scaleDown" src = "images/mbh-logo.png">
</div> 
</body>
</html>

The above example will produce the below output.

object-fit-property



         <<-- PREVIOUS                                                                                                 NEXT -->>









  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

1 comment:

  1. YogeshJune 1, 2019 at 12:34 PM


    This is an awesome post. Really very informative and creative contents.
    Graphic Design company in Chennai

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Thank you for reading this post. Please do not enter any spam link in the comment box.

Followers

Blog Archive

  • ►  2020 (4)
    • ►  October (1)
    • ►  September (1)
    • ►  August (2)
  • ▼  2019 (52)
    • ►  December (1)
    • ►  November (2)
    • ►  October (1)
    • ►  August (1)
    • ►  July (1)
    • ▼  May (11)
      • How to use css transition property? CSS Tutorial 29
      • How to use css transform property? CSS Tutorial 30
      • How to use css object-fit property? CSS Tutorial 28
      • How to use css filter property? CSS Tutorial 27
      • How to use css @import rule? CSS Tutorial 26
      • How to use css @media query? CSS Tutorial 25
      • How to use css @font-face rule? CSS Tutorial24
      • How to use css text shadow property? CSS Tutorial 23
      • How to use css border-image property? CSS Tutorial 22
      • How to use css pseudo elements? CSS Tutorial 21
      • How to use pseudo class selectors? CSS Tutorial 20
    • ►  April (10)
    • ►  March (6)
    • ►  February (3)
    • ►  January (16)
  • ►  2018 (54)
    • ►  December (27)
    • ►  November (5)
    • ►  May (5)
    • ►  April (4)
    • ►  February (3)
    • ►  January (10)
  • ►  2017 (17)
    • ►  December (9)
    • ►  November (8)

Popular Posts

  • How to use the main tag in html5?
  • How to use keygen tag in html5?
  • How to use html5 mark tag to highlight text?
  • How to start Online Business without money from home?
  • What is a search engine?

Contact Us

Name

Email *

Message *

About MyBlogHelp

Most of the posts, we share on this blog related to Affiliate Marketing, Organic Lead Generation, Digital Marketing, Social Media Marketing, Make Money Online, SEO, and web design.

Featured Post

LeadArk - Affiliate Marketing | Qualified Organic Lead Generation | LeadsArk Review

Copyright © MyBlogHelp– A Blog for Digital Marketing, Affiliate Marketing, Organic Lead Generation.
Design by Md. Abdussamad | MyBlogHelp.com