-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5eb0978
commit d909757
Showing
3 changed files
with
86 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
| 标题 | 标签 | | ||
| -------------------------------- | -------------- | | ||
| zig-zag-pattern(锯齿形背景图案) | visual(视觉的)) | | ||
| 标题 | 标签 | | ||
| ------------------------------- | -------------- | | ||
| zig-zag-pattern(锯齿形背景图案) | visual(视觉的) | | ||
|
||
创建锯齿形背景图案。 | ||
|
||
* 使用 background-color 设置白色背景。 | ||
* 使用具有四个 linear-gradient() 值的背景图像来创建锯齿形图案的各个部分。 | ||
* 使用 background-size 指定图案的大小。 使用 background-position 将图案的各个部分放置在正确的位置。 | ||
* 注意:元素的固定高度和宽度仅用于演示目的。 | ||
- 使用 background-color 设置白色背景。 | ||
- 使用具有四个 linear-gradient() 值的背景图像来创建锯齿形图案的各个部分。 | ||
- 使用 background-size 指定图案的大小。 使用 background-position 将图案的各个部分放置在正确的位置。 | ||
- 注意:元素的固定高度和宽度仅用于演示目的。 | ||
|
||
```html | ||
<div class="zig-zag"></div> | ||
``` | ||
|
||
```css | ||
.zig-zag { | ||
width: 240px; | ||
height: 240px; | ||
background-color: #fff; | ||
background-size: 60px 60px; | ||
background-repeat: repeat; | ||
background-position: -30px 0,-30px 0,0 0,0 0; | ||
background-image: linear-gradient(135deg, #000 25%,transparent 25%), | ||
linear-gradient(225deg, #000 25%,transparent 25%), | ||
linear-gradient(3155deg, #000 25%,transparent 25%), | ||
linear-gradient(455deg, #000 25%,transparent 25%); | ||
width: 240px; | ||
height: 240px; | ||
background-color: #fff; | ||
background-size: 60px 60px; | ||
background-repeat: repeat; | ||
background-position: -30px 0, -30px 0, 0 0, 0 0; | ||
background-image: linear-gradient(135deg, #000 25%, transparent 25%), | ||
linear-gradient(225deg, #000 25%, transparent 25%), linear-gradient( | ||
3155deg, | ||
#000 25%, | ||
transparent 25% | ||
), linear-gradient(455deg, #000 25%, transparent 25%); | ||
} | ||
``` | ||
|
||
> 应用场景 | ||
<iframe src="codes/css/html/zig-zag-pattern.html"></iframe> | ||
<div class="code-editor" data-url="codes/css/html/zebra-striped-list.html" data-language="html"></div> | ||
|
||
结果如下: | ||
|
||
<iframe src="codes/css/html/zebra-striped-list.html"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>counter</title> | ||
</head> | ||
|
||
<body> | ||
<div id="counter"></div> | ||
<button id="btn" type="button">点击我重新计数</button> | ||
<script> | ||
const counter = (selector, start, end, step = 1, duration = 2000) => { | ||
const $ = v => document.querySelector(v); | ||
let current = start, | ||
_step = (end - start) * step < 0 ? -step : step, | ||
timer = setInterval(() => { | ||
current += _step; | ||
$(selector).innerHTML = current; | ||
if (current >= end) { | ||
$(selector).innerHTML = end; | ||
clearInterval(timer); | ||
} | ||
}, Math.abs(Math.floor(duration / (end - start)))); | ||
return timer; | ||
}; | ||
counter('#counter', 1, 1000, 5, 2000); | ||
const btn = document.querySelector('#btn'); | ||
btn.onclick = () => counter('#counter', 1, 1000, 5, 2000); | ||
</script> | ||
</body> | ||
|
||
</html> |