Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 반응형
- 제이쿼리
- position
- 사이드바
- 문자열 자르기
- 클리핑마스크
- BNX사이트
- IT
- PHP
- 플렉스
- Poster
- MARGIN
- steak
- CLIPING MASK
- web
- HTML
- jQuery
- float
- 웹
- 레이아웃
- flex
- 드롭다운메뉴
- JavaScript
- 메소드
- 판화
- CSS
- Photoshop
- 자바스크립트
- sideproject
- Transform
Archives
- Today
- Total
코딩 슬라임 공방
자바스크립트 css 스타일 값에 변수 값 적용하기 본문
예를 들어 xxxx라는 이름을 가지고 있는 요소의 padding이나 margin 값을 변경할 때에는 이렇게 한다.
ex)
document.querySelector(".xxxx").style.paddingTop = "10px";
document.querySelector(".xxxx").style.paddingBottom = "10px";
document.querySelector(".xxxx").style.paddingRight = "10px";
document.querySelector(".xxxx").style.paddingLeft = "10px";
document.querySelector(".xxxx").style.marginTop = "10px";
document.querySelector(".xxxx").style.marginBottom = "10px";
document.querySelector(".xxxx").style.marginRight = "10px";
document.querySelector(".xxxx").style.marginLeft = "10px";
10px이라는 고정 값을 임의로 정해놓은 변수의 값으로 대채하고 싶을때는 이렇게 사용한다.
ex)
var i = 10 ;
document.querySelector(".xxxx").style.paddingTop = i + "px";
document.querySelector(".xxxx").style.paddingBottom = i + "px";
document.querySelector(".xxxx").style.paddingRight = i + "px";
document.querySelector(".xxxx").style.paddingLeft = i + "px";
document.querySelector(".xxxx").style.marginTop = i + "px";
document.querySelector(".xxxx").style.marginBottom = i + "px";
document.querySelector(".xxxx").style.marginRight = i + "px";
document.querySelector(".xxxx").style.marginLeft = i + "px";
'HTML_CSS_JAVA SCRIPT 수업' 카테고리의 다른 글
사이드 프로젝트 전체결합 1차 (0) | 2020.05.26 |
---|---|
자바스크립트 요소의 width값, height값 구하기 (0) | 2020.05.23 |
창작사이트 상단,인기상품리스트,상품리스트 결합 (0) | 2020.05.23 |
창작 사이트 상단, 인기상품리스트 결합 (0) | 2020.05.23 |
사이즈 비례 상자 만들기 (0) | 2020.05.22 |
Comments