May 30, 2021 Article blog
1. 1. List 3 new HTML5 tags and 3 new CSS3 features.
3. 3. A DIV is implemented with js-css3 to move 100px left at 50px per second
4. 4.CSS Implementation of three-column layout (left and right fixed 200px, intermediate adaptive)
// 临时存储
sessionStorage.setItem('c','tom')
// 永久存贮
localStorage.setItem('c','tom')
// 读取
localStorage.getItem('c')
// 删除
localStorage.removeItem("c");//逐条删
localStorage.clear();//删除全部
<style>
.box{
width: 100px;
height: 100px;
background-color:pink;
position: relative;
left: 0;
top: 0;
}
</style>
<body>
<div class="box"></div>
<script>
// 100*20=2000
// 获取box
let box= document.querySelector('.box')
let left = box.style.left
var leftnum = Number(left.split('px')[0]) //不要单位
var num = 1
var animate = setInterval(() => {
if(num>=100){
clearInterval(animate)
}
leftnum+=1
box.style.left = leftnum+'px'
num++
}, 20);
</script>
</body>
Dual wing layout: all float left, a box in the middle, padding separated from the width of both sides. There's margin-left on the left and right.
<style>
body {
min-width: 550px;
}
.col {
float: left;
}
#main {
width: 100%;
height: 400px;
background-color: #ccc;
}
#main-wrap {
margin: 0 200px 0 200px;
}
#left {
width: 200px;
height: 400px;
margin-left: -100%;
background-color: red;
}
#right {
width: 200px;
height: 400px;
margin-left: -200px;
background-color: #ff0000;
}
</style>
<body>
<div id="container">
<div id="main" class="col">
<div id="main-wrap"></div>
</div>
<div id="left" class="col"></div>
<div id="right"class="col"></div>
</div>
</body>
Grail layout: No boxes in the middle but padding.
<style>
#container{
padding: 0 190px 0 190px;
}
.col{
position: relative;
float: left;
}
#main{
width: 100%;
height: 400px;
background-color: #ddd;
}
#left{
width: 190px;
height: 400px;
background-color:red;
/* 离左边距本身的距离 */
margin-left: -100%;
/* 然后又自己向左移了本身的宽度*/
left: -190px;
}
#right{
width: 190px;
height: 400px;
background-color: yellow;
margin-left: -190px;
right: -190px;
}
</style>
<body>
<div id="container">
<div id="main" class="col"></div>
<div id="left" class="col"></div>
<div id="right"class="col"></div>
</div>
</body>
Expand the left and right layout
<style>
html,body{
height: 100%;
}
.left{
width: 256px;
height: 100%;
background-color: #ddd;
float: left;
}
.right{
width: 100%;
height: 100%;
margin-left: 256px;
background-color: rgb(230, 48, 48);
}
</style>
<body>
<div class="left"></div>
<div class="right"></div>
</body>
<style>
#canvas{
width: 500px;
height: 500px;
}
</style>
<body>
<canvas id="canvas"></canvas>
</body>
<script>
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
//画一个空心圆
ctx.beginPath();
// arc()方法是创建弧/曲线(用于创建圆或部分圆)
// context.arc(x,y,r,sAngle,eAngle,counterclockwise);
// 起始角为 0
// 结束角为 2*Math.PI
ctx.arc(100,75,50,0,2*Math.PI);
ctx.lineWidth=5;
ctx.strokeStyle="green";
// 使用 stroke()或fill()方法在画布上绘制实际的弧
ctx.stroke();//画空心圆
ctx.closePath();
//画一个实心圆
// ctx.beginPath();
// ctx.arc(200,100,50,0,360,false);
// ctx.fillStyle="red";//填充颜色,默认是黑色
// ctx.fill();//画实心圆
// ctx.closePath();
//空心和实心的组合
// ctx.beginPath();
// ctx.arc(100,100,50,0,360,false);
// ctx.fillStyle="red";
// ctx.fill();
// ctx.strokeStyle="green";
// ctx.stroke();
// ctx.closePath();
</script>
<style>
#box{
width: 100px;
height: 10px;
background-color: pink;
transition: all 1s ease;
}
#box:hover{
height: 100px;
}
</style>
<body>
<div id="box"></div>
</body>