-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulticol-rule-width.html
More file actions
54 lines (48 loc) · 1.84 KB
/
Copy pathmulticol-rule-width.html
File metadata and controls
54 lines (48 loc) · 1.84 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo</title>
<link rel="stylesheet" href="style.css">
<style>
.article {
column-count: 3;
column-gap: 32px;
column-rule: var(--rule-width, 2px) solid #c00;
}
.article p {
margin: 0 0 1em;
}
output {
font-variant-numeric: tabular-nums;
}
</style>
</head>
<body>
<div class="controls">
<label>
column-rule-width:
<input type="range" id="width" min="1" max="32" step="1" value="2">
<output id="widthValue">2px</output>
</label>
<p class="note">column-gapは32pxに固定しています。線を太くしても、段の幅も、テキストが折り返す位置も変わりません。</p>
</div>
<div class="article" id="article">
<p>column-ruleの線は隙間の中央に描かれ、レイアウト上の幅を取りません。borderのように要素を押し広げないので、線を太くしてもテキストの位置は変わりません。</p>
<p>スライダーを動かして、段の幅とテキストの折り返し位置を見てみてください。線だけが太くなり、そのほかは何も動きません。</p>
<p>borderで同じことをすると、線の太さのぶんだけ場所を取るので、要素や中身の幅・位置が変わってしまいます。</p>
</div>
<script>
const width = document.getElementById("width");
const article = document.getElementById("article");
const widthValue = document.getElementById("widthValue");
const update = () => {
article.style.setProperty("--rule-width", `${width.value}px`);
widthValue.textContent = `${width.value}px`;
};
width.addEventListener("input", update);
update();
</script>
</body>
</html>