자바에서 위치를 설정할 때 'calc'함수를 사용할 수 있습니까?자바 스크립트에서 'calc'를 사용할 수 있습니까?
ePopup.style.top = "calc (100px - 1.5em);"
자바에서 위치를 설정할 때 'calc'함수를 사용할 수 있습니까?자바 스크립트에서 'calc'를 사용할 수 있습니까?
ePopup.style.top = "calc (100px - 1.5em);"
예, calc()
은 자바 스크립트에서 스타일을 설정할 때 작동합니다.
작업 예 :
var innerDiv = document.getElementsByClassName('inner-div')[0];
function growInnerDiv() {
innerDiv.style.width = 'calc(100% + 224px)';
}
innerDiv.addEventListener('click', growInnerDiv, false);
.outer-div {
display: inline-block;
width: 200px;
height: 100px;
padding: 12px;
border: 1px solid rgb(255,0,0);
background-color: rgb(255,255,0);
}
.inner-div {
width: 100px;
height: 100px;
color: rgb(255, 255, 255);
font-weight: bold;
text-align: center;
line-height: 100px;
font-family: arial, helvetica, sans-serif;
background-color: rgb(255,0,0);
cursor: pointer;
transition: all 0.5s linear;
}
<div class="outer-div">
<div class="inner-div">Click Me</div>
<div>
당신이 게시하기 전에 그것을 시도하는 경우? – raven
물론 나는 이것을 시도했지만 작동하지 않았다. 내가 무언가를 구문 적으로 부정확하게했거나 본질적으로 작동하지 않기 때문에 작동하지 않았는가? – NickC