Menu



Manage

파일 목록
Study_Web > 3week/Example8-2.html Lines 31 | 1.0 KB
다운로드

                        <!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>
<script>
    function change() {
        let span = document.getElementById("mySpan");
        span.style.color = "green"; // 글자 색 green
        span.style.fontSize = "30px"; // 글자 크기는 30픽셀
        span.style.display = "block"; // 블록 박스로 변경
        span.style.width = "6em"; // 박스의 폭. 6 글자 크기
        span.style.border = "3px dotted magenta"; // 3픽셀 점선 magenta 테두리
        span.style.margin = "20px"; // 상하좌우 여백 20px
    }
</script>

<body>
    <h3>CSS 스타일 동적 변경</h3>
    <hr>
    <p style="color:blue">이것은
        <span id="mySpan" style="color:red">문장입니다.</span>
    </p>
    <input type="button" value="스타일변경" onclick="change()">
</body>

</html>