-
-
Save kobitoDevelopment/7dab101b5c513e4193d60699641555fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--padding --> | |
<div class="square"> | |
<div class="inner"> | |
<!-- 比率等倍ボックスに記述したい内容 --> | |
</div> | |
</div> | |
<!-- aspect-ratio --> | |
<div class="hoge"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* padding */ | |
.square { | |
position: relative; | |
width: 30%; //希望の横幅 | |
padding-top: 30%; // 横幅=高さに設定 | |
background: blue; //デバッグ用背景 | |
.inner { | |
position: absolute; | |
top: 0; | |
left: 0; | |
} | |
} | |
/* aspect-ratio */ | |
.hoge { | |
width: 30%; | |
aspect-ratio: 1/1; // X軸/Y軸 1/1にすることでwidth30%で算出した数値が高さに付与される | |
background: blue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment