Object-fit and object-position

Developer
Size
2,727 Kb
Views
24,288

How do I make an object-fit and object-position?

Testing object-fit and object-position properties and polyfill.http://helloanselm.com/2013/fix-image-resizing-with-object-fit/. What is a object-fit and object-position? How do you make a object-fit and object-position? This script and codes were developed by Joey Hoer on 14 September 2022, Wednesday.

Object-fit and object-position Previews

Object-fit and object-position - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>object-fit and object-position</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <figure class="bg"> <figcaption class="description">background-image</figcaption>
</figure>
<figure> <img src="//i.jyhr.co/cdpn/colors.jpg" /> <figcaption class="description">&lt;img&gt;</figcaption>
</figure> <script src='http://jyhr.co/cdpn/modernizr.objectfit.js'></script> <script src="js/index.js"></script>
</body>
</html>

Object-fit and object-position - Script Codes CSS Codes

.bg { background-image: url(//i.jyhr.co/cdpn/colors.jpg); background-position: 50%; background-size: cover;
}
img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; -o-object-fit: cover; object-fit: cover; -o-object-position: 50%; object-position: 50%; overflow: hidden;
}
figcaption { position: absolute; bottom: 0.5em; right: 0.5em; font-family: monospace, monospace; color: #fff; background-color: rgba(0, 0, 0, 0.75); padding: 0.5em;
}
figure { position: relative; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; margin: 0;
}
html, body { height: 100%; width: 100%; overflow: hidden; display: -webkit-box; display: -ms-flexbox; display: flex;
}
img, figure { vertical-align: middle;
}

Object-fit and object-position - Script Codes JS Codes

Modernizr.load({ test: Modernizr['object-fit'], nope: ['https://cdn.rawgit.com/anselmh/object-fit/master/dist/polyfill.object-fit.css', 'https://cdn.rawgit.com/anselmh/object-fit/master/dist/polyfill.object-fit.min.js'], complete: function(){ if (!Modernizr['object-fit']) { objectFit.polyfill({ selector: 'img', // this can be any CSS selector fittype: 'cover' // either contain, cover, fill or none }); } }
})
Object-fit and object-position - Script Codes
Object-fit and object-position - Script Codes
Home Page Home
Developer Joey Hoer
Username joeyhoer
Uploaded September 14, 2022
Rating 3
Size 2,727 Kb
Views 24,288
Do you need developer help for Object-fit and object-position?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Joey Hoer (joeyhoer) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!