윤곽선을 오프셋하려면 outlineOffset을 사용하세요. 재산. 테두리 가장자리 너머로 윤곽선을 그릴 수 있습니다.
다음 코드를 실행하여 외곽선을 오프셋하고 JavaScript로 테두리 가장자리 너머로 그릴 수 있습니다.
예시
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 450px;
background-color: orange;
border: 3px solid red;
margin-left: 20px;
}
</style>
</head>
<body>
<p>Click below to add Outline Offset.</p>
<div id="box">
<p>This is a div. This is a div. This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div. This is a div. This is a div.</p>
</div>
<br>
<button type="button" onclick="display()">Set Outline Offset</button>
<br>
<script>
function display() {
document.getElementById("box").style.outline = "thick solid";
document.getElementById("box").style.outlineColor = "#5F5F5F";
document.getElementById("box").style.outlineOffset = "7px";
}
</script>
</body>
</html>