{"id":4259,"date":"2024-10-24T09:01:29","date_gmt":"2024-10-24T14:01:29","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=4259"},"modified":"2024-10-24T09:01:30","modified_gmt":"2024-10-24T14:01:30","slug":"9-16","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/9-16\/","title":{"rendered":"9 \/ 16"},"content":{"rendered":"\n<p>The other day I needed to quickly see pixel dimensions that were <em>exactly<\/em> in a 9 \/ 16 aspect ratio. Like: 180 \/ 320. That&#8217;s perfectly in that ratio. You might be able to think of that one in your head, but how about 351 \/ 624? That&#8217;s harder to think of. And I wanted to visualize it somehow, so I ended up making a web component (<code>&lt;aspect-ratio-machine><\/code>) that would display a resizable box in that exact aspect ratio (thanks to CSS&#8217; <code>aspect-ratio<\/code>) then also display the pixel dimensions as well.<\/p>\n\n\n\n<div class=\"wp-block-cp-codepen-gutenberg-embed-block cp_embed_wrapper\"><iframe id=\"cp_embed_GRzOZXq\" src=\"\/\/codepen.io\/anon\/embed\/GRzOZXq?height=650&amp;theme-id=47434&amp;slug-hash=GRzOZXq&amp;default-tab=js,result\" height=\"650\" scrolling=\"no\" frameborder=\"0\" allowfullscreen allowpaymentrequest name=\"CodePen Embed GRzOZXq\" title=\"CodePen Embed GRzOZXq\" class=\"cp_embed_iframe\" style=\"width:100%;overflow:hidden\">CodePen Embed Fallback<\/iframe><\/div>\n\n\n\n<p>That&#8217;s <a href=\"https:\/\/frontendmasters.com\/blog\/light-dom-only\/\">a light-DOM-only web component<\/a> that just &#8220;enhances&#8221; otherwise normal HTML. Perhaps it&#8217;s not bursting with usefulness, but it was useful to me. <\/p>\n\n\n\n<p>The reason it was useful, by the way, is that I was playing around with YouTube Shorts, and the thing I was using to upload was <em>very<\/em> strict that the video was <em>exactly<\/em> 9 \/ 16 ratio. I wanted to record somewhat arbitrary sections of my screen, then crop and arrange and stuff later into a size that accommodated 9 \/ 16, and I had to type in the pixel dimensions manually in the particular software I was using to get there.<\/p>\n\n\n\n<p>I also needed integers. A failing of my first example above is that the resizer was happy to do sub-pixel values, which were not useful to me as the software I was using to make a video canvas size did not accept them.<\/p>\n\n\n\n<p>I also realized that actually seeing a box in the 9 \/ 16 size wasn&#8217;t particularly useful. I know what a rectangle looks like. So instead a built a more simple solution with a range slider that updated numbers on the screen.<\/p>\n\n\n\n<div class=\"wp-block-cp-codepen-gutenberg-embed-block cp_embed_wrapper\"><iframe id=\"cp_embed_vYbWKBK\" src=\"\/\/codepen.io\/anon\/embed\/vYbWKBK?height=450&amp;theme-id=47434&amp;slug-hash=vYbWKBK&amp;default-tab=result\" height=\"450\" scrolling=\"no\" frameborder=\"0\" allowfullscreen allowpaymentrequest name=\"CodePen Embed vYbWKBK\" title=\"CodePen Embed vYbWKBK\" class=\"cp_embed_iframe\" style=\"width:100%;overflow:hidden\">CodePen Embed Fallback<\/iframe><\/div>\n\n\n\n<p>Niche problem; niche solution. But hey I like building little tools for myself so I thought I&#8217;d share. <a href=\"https:\/\/shoptalkshow.com\/609\/\">&#8220;Home Cooked Apps&#8221;<\/a> as it were.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other day I needed to quickly see pixel dimensions that were exactly in a 9 \/ 16 aspect ratio. Like: 180 \/ 320. That&#8217;s perfectly in that ratio. You might be able to think of that one in your head, but how about 351 \/ 624? That&#8217;s harder to think of. And I wanted [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4262,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[156,7,36],"class_list":["post-4259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-post","tag-aspect-ratio","tag-css","tag-web-components"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/10\/ratio.jpg?fit=612%2C406&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/4259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=4259"}],"version-history":[{"count":2,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/4259\/revisions"}],"predecessor-version":[{"id":4263,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/4259\/revisions\/4263"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/4262"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=4259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=4259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=4259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}