css3

基础

html 复制代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>style</title>
		<!-- link(外部样式)和style(内部样式)优先级相同,重复写会覆盖 -->
		<link rel="stylesheet" href="main.css"/>
		<style>
			/* 标签选择器 */
			h1 {
				background-color: aquamarine;
				/* !important 表示优先级最高 */
				color: black !important;
			}
			/* 类选择器 */
			.class1{
				color: red;
			}
			/* id选择器 */
			#id1{
				color: blue;
			}
			/* 后代选择器:#id2内所有的p标签 */
			#id2 p{
				color: royalblue;
			}
			/* 子代选择器:#id2的第一级子标签 */
			#id2 > p{
				text-decoration-line: underline;
			}
			/* 伪类选择器:需要有a的选择器 */
			a{
				
			}
			/* 鼠标置于a标签,颜色改变 */
			a:hover {
				color: red;
			}
			a:link{
				color: yellow;
			}
			a:visited{
				color: green;
			}
			a:active{
				color: blue;
			}
			body{
				background-color: aliceblue;
				background-image: url("../img/demo2.png");
				background-repeat: no-repeat;
				background-size: 200px 200px;
				/* 背景固定 */
				background-attachment: fixed;
				/* 背景随滚动条滚动 */
				/* background-attachment: scroll; */
				background-position-x: center;
				background-position-y: center;
				/* xy轴占比 */
				background-position: 10% 10%;
			}
			span{
				/* font-size: 20px;
				font-family: "Microsoft YaHei UI";
				font-weight: bold;
				font-style: italic; */
				/* 连写要注意顺序 */
				font: italic bold 30px "Microsoft YaHei UI";
			}
			p{
				font-size: 16px;
				width: 120px;
				color: crimson;
				line-height: 24px;
				/* 缩进 */
				text-indent: 1em;
			}
		</style>
	</head>
	<body>
		<!-- 行内样式优先级高于内部样式 -->
		<h1 style="background-color: aqua; text-align: center;">111</h1>
		<h1 class="class1">222</h1>
		<h1 id="id1">333</h1>
		<div id="id2">
			<p>p1</p>
			<div>
				<p>p2</p>
			</div>
		</div>
		<a href="">百度</a>
	</body>
</html>

计时器

html 复制代码
<h1 id="clock"></h1>
<script>
	const formatTime = n => n < 10 ? '0' + n : n;
	function updateClock(){
		const date = new Date();
		const hours = formatTime(date.getHours());
		const minutes = formatTime(date.getMinutes());
		const seconds = formatTime(date.getSeconds());
		const clock = document.getElementById("clock");
		clock.textContent = `${hours}:${minutes}:${seconds}`;
	}
	setInterval(updateClock,1000);
</script>
相关推荐
Pu_Nine_915 小时前
10 分钟上手 ECharts:从“能跑”到“生产级”的完整踩坑之旅
前端·javascript·echarts·css3·html5
咔咔一顿操作1 天前
【CSS 3D 交互】打造沉浸式 3D 照片墙:结合 JS 实现拖拽交互
前端·javascript·css·3d·交互·css3
β添砖java1 天前
CSS3核心技术
前端·css·css3
猫头虎-前端技术2 天前
浏览器兼容性问题全解:CSS 前缀、Grid/Flex 布局兼容方案与跨浏览器调试技巧
前端·css·node.js·bootstrap·ecmascript·css3·媒体
索迪迈科技2 天前
Flex布局——详解
前端·html·css3·html5
咔咔一顿操作2 天前
【CSS 3D 实战】从零实现旋转立方体:理解 3D 空间的核心原理
前端·css·3d·css3
DONG9132 天前
深度解析CSS单位与媒体查询:构建现代化响应式布局的核心技术
前端·css·html·css3·媒体
高级测试工程师欧阳2 天前
CSS 基础概念
前端·css·css3
奶昔不会射手2 天前
css3之grid布局
前端·css·css3
小菜全3 天前
uniapp基础组件概述
前端·css·vue.js·elementui·css3