效果展示:
备忘录打卡效果展示
所用技术:
- HTML
- CSS
- JavaScript
代码展示:
Html:
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>100dayscss #27</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="frame">
<div class="center">
<section class="todo-cmp">
<header class="todo-cmp__header">
<h2 id="day"></h2>
<p id="data"></p>
</header>
<ul class="todo-cmp__list">
<li>
<label for="todo-01">
<input id="todo-01" type="checkbox">
<span>打开模板</span>
</label>
</li>
<li>
<label for="todo-02">
<input id="todo-02" type="checkbox">
<span>创建待办事项列表</span>
</label>
</li>
<li>
<label for="todo-03">
<input id="todo-03" type="checkbox">
<span>写点什么</span>
</label>
</li>
<li>
<label for="todo-04">
<input id="todo-04" type="checkbox">
<span>完成任务</span>
</label>
</li>
</ul>
</section>
</div>
</div>
<script src="js/base.js"></script>
</body>
</html>
Css:
@charset "UTF-8";
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600);
.frame {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
height: 400px;
margin-top: -200px;
margin-left: -200px;
border-radius: 2px;
box-shadow: 4px 8px 16px 0 rgba(0, 0, 0, 0.1);
overflow: hidden;
font-family: 'Open Sans', Helvetica, sans-serif;
/* 抗锯齿,让文字更清晰 */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-image: linear-gradient(45deg, #ff9700, #ed1c24);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fda231', endColorstr='#fdca31',GradientType=1 );
}
.center {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.todo-cmp {
background: #ffffff;
color: #497081;
padding: 10px 30px;
border-radius: 5px;
box-shadow: 2px 2px 14px rgba(0, 0, 0, 0.15);
width: 180px;
}
.todo-cmp__header {
text-align: center;
padding: 10px 0;
border-bottom: 1px solid #ddd;
}
.todo-cmp__header h2 {
font-weight: 600;
font-size: 18px;
margin: 4px auto;
padding: 0;
}
.todo-cmp__header p {
padding: 0 0 5px;
margin: 4px auto;
font-size: 0.8rem;
}
.todo-cmp__list {
list-style: none;
padding: 0;
}
.todo-cmp__list li {
padding: 10px 0 15px;
margin: 0;
text-align: left;
width: 100%;
}
.todo-cmp__list li label {
cursor: pointer;
font-size: 0.82rem;
width: 100%;
display: block;
}
.todo-cmp__list li label input {
float: right;
opacity: 0;
}
.todo-cmp__list li label span {
position: relative;
display: block;
transition: all 550ms ease-in-out;
}
/* 兄弟选择器 */
.todo-cmp__list li label input + span::after {
content: "";
display: block;
border: 1px solid #497081;
border-radius: 13px;
height: 13px;
width: 13px;
position: absolute;
right: 0;
top: 1px;
z-index: 10;
transition: all 550ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.todo-cmp__list li label input + span::before {
content: "✔";
display: block;
font-size: 22px;
height: 13px;
width: 13px;
position: absolute;
right: -2px;
top: -8px;
z-index: 10;
opacity: 0;
}
.todo-cmp__list li label input:checked + span {
color: #ccc;
transition: all 550ms ease-in-out;
}
.todo-cmp__list li label input:checked + span::after {
opacity: 0;
height: 17px;
width: 17px;
top: -2px;
right: -2px;
}
.todo-cmp__list li label input:checked + span::before {
opacity: 1;
transition: all 550ms ease-in-out;
}
JavaScript:
var MyDate = new Date()
var years = MyDate.getFullYear()//获取当前年
var months = (MyDate.getMonth())+1//获取当前月
var date = MyDate.getDate()//获取当前日
var day = MyDate.getDay()//获取当前星期几
var days = ["日","一","二","三","四","五","六"]
var today_date = years+"年"+months+"月"+date+"日"
var today_day = "星期"+days[day]
document.getElementById("data").innerHTML = today_date
document.getElementById("day").innerText = today_day