2018/03/25
css
備忘録です。
参考サイト
youtubeの動画をCSSでアスペクト比固定で表示する。
HTML
<div class="iframe-wrapper"> <!-- youtubeの動画 --> <iframe width="560" height="315" src="https://www.youtube.com/embed/cl-KAl2Xlug" frameborder="0" allowfullscreen></iframe> <div>
CSS
iframe {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.iframe-wrapper {
padding-bottom: 56.25%;
/* 9/16*100=56.25 アスペクト比は16:9 */
height: 0;
position: relative;
}
youtube以外にもiframeを使っている場合には、親要素にid指定をすると特定のiframeだけに適用されます。
2026/11/03
AI
2026/11/02
JQuery
css
2026/11/01
車
2026/10/31
神社
御朱印
2026/10/30
AI
Wordpress
AIが書いた原稿をWordPressの「ブロック」に変換して下書きに──Markdownで書かせる理由と、変換で決めた5つのこと