+ 2

What's this?

Can anyone please help me to understand what's going on here? Html: <div style="--aspect-ratio:16/9;"> <iframe width="560" height="315" src="https://www.youtube.com/embed/2N_sUmpjzZk" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe> CSS: [style*="--aspect-ratio"] { > :first-child { width: 100%; } > img { height: auto; } @supports (--a:b) { position: relative; &::before { content: ""; display: block; padding-bottom: calc(100% / (var(--aspect-ratio))); } Or where can I get some information about this?

25th Jul 2018, 6:46 PM
Rejwan Islam
Rejwan Islam - avatar
8 ответов
+ 8
Calviղ yes, that's SCSS 😊 Rezowan Islam Rizvy (RIR) it's a preprocessor, it gives CSS superpowers :) it's based on Ruby and you need to compile it for browsers to be able to run it. But basically that code snippet is using mixins (like functions) and nesting syntax. Learn more about it here: https://sass-lang.com/guide
26th Jul 2018, 4:27 AM
Pao
Pao - avatar
+ 5
Rezowan Islam Rizvy (RIR) Type @(name of the person) and choose it from the list that appears.
26th Jul 2018, 9:10 AM
Harsh
Harsh - avatar
+ 3
For aspect ratio - scroll down to “The psuedo element tactic: https://css-tricks.com/aspect-ratio-boxes/ The iframe tag is just being used to add a youtube video.
25th Jul 2018, 6:56 PM
Agent
Agent - avatar
+ 3
thanks a lot Stellar Fox . and can you say, why there's written "mod" beside your name? Pao also have it. but me and Calviղ don't have.
27th Jul 2018, 11:41 AM
Rejwan Islam
Rejwan Islam - avatar
27th Jul 2018, 12:08 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
/* the following set the style attribute which contains word "--aspect-ratio" */ [style*="--aspect-ratio"] { > :first-child { width: 100%; } /* first element */ > img { height: auto; } /* the following style is for browsers support css variable */ @supports (--a:b) { position: relative; &::before { content: ""; display: block; padding-bottom: calc(100% / (var(--aspect-ratio))); } I think this is CSS preprocessing codes, can it actually work from CSS directly or is this a codepen.io code ?
26th Jul 2018, 1:14 AM
Calviղ
Calviղ - avatar
+ 2
yes calvin it's a codepen.io code.
26th Jul 2018, 4:21 AM
Rejwan Islam
Rejwan Islam - avatar
+ 2
Thanks a lot pao. But How to mention somebody on comment? (like you did)
26th Jul 2018, 4:30 AM
Rejwan Islam
Rejwan Islam - avatar