I'm

Developer, Designer, Photographer

GET IN TOUCH

  • Buk-gu, Busan, Republic of Korea
  • ungdoli0916@naver.com
  • Kakao ID : Ungdoli
Your message has been sent. Thank you!
(즐거웅코드) 자바스크립트 margin-bottom 변경하기

· 즐거'웅' 코드 (Source)/HTML & CSS & JAVASCRIPT
2021. 3. 29. 20:49

반응형
JAVASCRIPT
1
2
3
<script>
    document.getElementById('(아이디명)').style.marginBottom = (값);
</script>
예제 소스
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<input type="number" id="margin_value" placeholder="margin-bottom 값 입력"/>
<button onclick="test()">margin-bottom 변경하기</button>
 
<div id="test_obj"></div>
 
<style>
    div {
        width: 200px;
        height: 50px;
        border: 1px solid #bbbbbb;
        background-color: #fbfbfb;
    }
</style>
 
<script>
    function test() {
        var margin_value = document.getElementById('margin_value').value;
        document.getElementById('test_obj').style.marginBottom = margin_value;
    }
</script>
구현 예시
반응형