HTML입문

HTML_멀티미디어태그(이미지,iframe,스크립트)_22.04.06(wed)

양빵빵 2022. 4. 7. 15:32

이미지의 가로나 세로 중 하나만 지정하면 나머지 부분은 비율에 맞춰 자동조정 된다.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <img src="../images/basic.jpg" alt="송아지">

    <img width='200' src="../images/basic.jpg" alt="송아지">
    <!-- 가로 세로 중 하나만 지정하면 나머지부분은 비율에 맞춰 자동조정 -->

    <img width='200px' height = '100px' src="../images/basic.jpg" alt="송아지">

    <a href="http://www.naver.com" target="_blank">
        <img src="../images/basic.jpg" alt="송아지">
    </a>


</body>
</html>
iframe 사용시 width, height 조정 src에 보여주고 싶은 컨텐츠의 위치를 입력 (상대경로 or 직접경로)

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   
    <iframe width="896" height="567" src="https://www.youtube.com/embed/GBkR7ztxhTw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
   
    <iframe width="100%" height ="800px" src="http://soongu.github.io" frameborder="0"></iframe>
   

    <iframe width="896" height="567" src="https://www.youtube.com/embed/GBkR7ztxhTw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
   

</body>
</html>
 
자바스크립트 기능을 사용하여 오렌지색 박스를 누르면 레드 박스로 변하면서 박스줄이기 메시지가 발생.

*자바 스크립트 맛보기*

 

메시지 발생 (자바스크립트 기능)

 

박스를 클릭하면 오렌지색이 빨간색으로 바뀐 것을 확인 할 수 있다.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

<style>
        .box {
        width: 300px;
        height: 300px;
        background : orange;
        margin : 100px;
</style>


</head>
<body>

    <div class="box">

        <script>
            const $box = document.querySelector('.box');
            $box.onclick = e => {
                alert('박스 줄이기!');
                $box.style.background = 'red';
                $box.style.width = '150px';
                $box.style.height = '150px';
            };
           
            </script>


    </div>


</body>
</html>