Scale To Fit
How do I make an scale to fit?
Scale content to remain inside the bounds of its parent whilst maintaining aspect ratio.. What is a scale to fit? How do you make a scale to fit? This script and codes were developed by Lukejacksonn on 30 November 2022, Wednesday.
Scale To Fit - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Scale To Fit</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <p>CSS Scale content to fit inside the bounds of its parent whilst maintaining some aspect ratio.</p>
<hr />
<div> <iframe src="http://lukejacksonn.com" frameborder="0"></iframe>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Scale To Fit - Script Codes CSS Codes
html { box-sizing: border-box;
}
*, *:before, *:after { box-sizing: inherit;
}
body { width: 100vw; height: 100vh; display: flex; flex-flow: column nowrap; font-family: "Helvetica", sans-serif; background: #ba68c8;
}
div { flex: 100%; width: 100%; overflow: hidden; display: flex; flex-flow: column nowrap; align-items: center; justify-content: center;
}
iframe { min-width: 800px; min-height: 500px; background: #fff;
}
p { display: block; padding: 3rem; max-width: 480px; color: #fff; text-align: center; margin: 0 auto; line-height: 150%;
}
hr { width: 90%; opacity: 0.5;
}
Scale To Fit - Script Codes JS Codes
$(function() { // fitInParent jQuery Plugin // https://github.com/lukejacksonn $.fn.fitInParent = function(boost) { boost = boost || 1; return this.each(function() { var $elem = $(this); var $parent = $elem.parent(); var xscale = $parent.width() / $elem.outerWidth()*boost; var yscale = $parent.height() / $elem.outerHeight()*boost; var scale = xscale > yscale ? yscale : xscale; $elem.css('transform','scale(' + scale + ')'); }); };
})
// Window resize listener
// Fits element to parent when viewport resizes
$(window).resize(function() { $('iframe').fitInParent(0.8);
});
// Iframe load listener
// Fits element to parent when iframe loads
$('iframe, window').load(function() { $(this).fitInParent(0.8);
});
Developer | Lukejacksonn |
Username | lukejacksonn |
Uploaded | November 30, 2022 |
Rating | 3 |
Size | 2,342 Kb |
Views | 12,144 |
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!
Name | Size |
Responsive Slider | 4,049 Kb |
Favorite Heart | 2,921 Kb |
Peeky Password | 2,409 Kb |
Perspective Generator | 4,313 Kb |
Sliding Drawers | 3,302 Kb |
Springy Select | 2,468 Kb |
Pinger | 4,434 Kb |
Complex Flexbox Layouts | 4,892 Kb |
Hero Flex-list | 5,064 Kb |
Flexbox Masonry | 6,547 Kb |
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!
Name | Username | Size |
Improved Page Flipping Effect | Usaphp | 5,201 Kb |
SVG hamburger menu button | Elifitch | 2,602 Kb |
Portfolio Landing Page | FDfranklin | 3,585 Kb |
Codero Sitemap | S1m0ne | 28,169 Kb |
Tree growth tests | Orchard | 3,818 Kb |
SlideupBoxes | Gavra | 23,772 Kb |
Shopping cart | Andiio | 6,581 Kb |
Drop Cap | Gsaiki | 1,571 Kb |
Project MMetro beta | Atomicsong | 5,157 Kb |
JavaScript Animation | Rcmeisty | 4,581 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!