๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
CSS๐Ÿ”ง/๋ฐ˜์‘ํ˜•

๋ชจ๋ฐ”์ผ ์œ ํŠœ๋ธŒ ๋น„์œจ์กฐ์ ˆ

by hyojinny 2022. 11. 16.

 

๋ชจ๋ฐ”์ผ์—์„œ ์œ ํŠœ๋ธŒ ์‚ฝ์ž…์‹œ ๋ฐํƒ‘๊ณผ ๋™์ผํ•˜๊ฒŒ ๋„ฃ์—ˆ์„๋•Œ ๊นจ์ง

css ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์ค˜์•ผํ•œ๋‹ค. 

 


 

 

          <div class="youtube">
            <iframe width="100%" height="100%" src="https://www.youtube.com/embed/ONpDtp-mPvY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
          </div>

div ๋กœ ํ•œ๋ฒˆ ๊ฐ์•„์ฃผ๊ณ  width / height ์„ 100% ๋กœ ๋งž์ถ˜๋‹ค. 

 

 


.main_best .youtube {
  margin-top: 60px;
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}
.main_best .youtube iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

 

์˜์ƒ ๋น„์œจ์€ 16:9 ์ด๊ธฐ๋•Œ๋ฌธ์— 

์˜พ์ด๋ฅผ ๊ฝ‰ ์ฐจ๊ฒŒ 100% ๋กœ ์ค€๋‹ค๋ฉด

 

16 : 9 X100

16 : 900 

900 / 6 = 56.25%

 

 

 

์ฆ‰ 56.25% ๋น„์œจ๋กœ ์•„๋ž˜๋ฅผ ๋Š˜๋ ค์ฃผ๋ผ๋Š” ๋œป 

 

 

 

 

๋Œ“๊ธ€