feat: 添加 使用html 笔记
parent
0ccf89b8b4
commit
69247d859a
@ -0,0 +1,16 @@
|
|||||||
|
.demo-outer {
|
||||||
|
background-color: green;
|
||||||
|
padding: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.demo-inner {
|
||||||
|
width: 400px;
|
||||||
|
height: 100px;
|
||||||
|
line-height: 96px;
|
||||||
|
margin: 0 auto;
|
||||||
|
border: 2px solid darkorange;
|
||||||
|
background-color: cadetblue;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
|
||||||
|
/*#region*/
|
||||||
|
.container {
|
||||||
|
/* width: 700px; */
|
||||||
|
min-height: 400px;
|
||||||
|
margin: 0px auto;
|
||||||
|
|
||||||
|
background-color: purple;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
justify-content: space-evenly;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
width: 200px;
|
||||||
|
height: 100px;
|
||||||
|
line-height: 100px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item::after {
|
||||||
|
content: "点我变色";
|
||||||
|
}
|
||||||
|
|
||||||
|
.item1 {
|
||||||
|
background-color: blueviolet;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item2 {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item3 {
|
||||||
|
background-color: skyblue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item4 {
|
||||||
|
background-color: coral;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item5 {
|
||||||
|
background-color: deeppink;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item6 {
|
||||||
|
background-color: forestgreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item7 {
|
||||||
|
background-color: saddlebrown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #endregion */
|
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>笔记本直接引用外部 html 文件</title>
|
||||||
|
<link rel="stylesheet" href="./css/index.css">
|
||||||
|
<!-- 相对于notebook文件的路径 -->
|
||||||
|
<link rel="stylesheet" href="./WebSite/css/index.css">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>html中引用的外部css文件、js文件路径要相对于笔记本文件而不是html本身的路径。</h2>
|
||||||
|
<div class="container">
|
||||||
|
<div class="item item1" onclick="alert(1)"></div>
|
||||||
|
<div class="item item2"></div>
|
||||||
|
<div class="item item3"></div>
|
||||||
|
<div class="item item4"></div>
|
||||||
|
<div class="item item5"></div>
|
||||||
|
<div class="item item6"></div>
|
||||||
|
<div class="item item7"></div>
|
||||||
|
</div>
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
<!-- 相对于notebook文件的路径 -->
|
||||||
|
<script src="./WebSite/js/index.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,15 @@
|
|||||||
|
// #region 切换背景颜色
|
||||||
|
var flag =false;
|
||||||
|
document.getElementById("js-file-test").onclick = function()
|
||||||
|
{
|
||||||
|
if(flag)
|
||||||
|
{
|
||||||
|
event.currentTarget.style.backgroundColor = "goldenrod";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event.currentTarget.style.backgroundColor = "green";
|
||||||
|
}
|
||||||
|
flag = !flag;
|
||||||
|
};
|
||||||
|
// #endregion
|
@ -0,0 +1,20 @@
|
|||||||
|
// #region 随机背景色
|
||||||
|
|
||||||
|
function GetRandomColor() {
|
||||||
|
var r = Math.floor(Math.random() * 255);
|
||||||
|
var g = Math.floor(Math.random() * 255);
|
||||||
|
var b = Math.floor(Math.random() * 255);
|
||||||
|
|
||||||
|
return "rgb(" + r + "," + g + "," + b + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
function ChangeColor(event){
|
||||||
|
event.currentTarget.style.backgroundColor = GetRandomColor();
|
||||||
|
};
|
||||||
|
|
||||||
|
//设置单击事件
|
||||||
|
var items = document.getElementsByClassName("item");
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
items[i].onclick = ChangeColor;
|
||||||
|
}
|
||||||
|
// #endregion
|
Loading…
Reference in New Issue