css3实现自行车

364 阅读1分钟

效果图

代码

<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>CSS3 钟表</title>
	<style>

		.clock {
			width: 200px;
			height: 200px;
			margin: 100px auto;
			border: 10px solid #000;
			border-radius: 110px;
			position: relative;
		}

		.line {
			width: 4px;
			height: 200px;
			background-color: #CCC;
			position: absolute;
			left: 50%;
			margin-left: -2px;

		}


		.line1 {
			transform: rotate(30deg);
		}

		.line2 {
			transform: rotate(60deg);
		}

		.line3 {
			transform: rotate(90deg);
		}

		.line4 {
			transform: rotate(120deg);
		}

		.line5 {
			transform: rotate(150deg);
		}

		.line6 {
			transform: rotate(180deg);
		}

		.cover {
			width: 160px;
			height: 160px;
			position: absolute;
			left: 50%;
			top: 50%;
			margin: -80px 0 0 -80px;
			border-radius: 50%;
			background-color: #FFF;
		}

		.hour {
			width: 6px;
			height: 50px;
			background-color: #000;

			position: absolute;
			left: 50%;
			bottom: 50%;
			margin-left: -3px;

			transform-origin: bottom;

			animation: move 216000s steps(60) infinite;

		}

		.minutes {
			width: 4px;
			height: 60px;
			background-color: #000;

			position: absolute;
			left: 50%;
			bottom: 50%;
			margin-left: -2px;

			transform-origin: bottom;

			animation: move 3600s steps(60) infinite;
		}

		.seconds {
			width: 2px;
			height: 70px;
			background-color: red;

			position: absolute;
			left: 50%;
			bottom: 50%;
			margin-left: -1px;

			transform-origin: bottom;

			animation: move 60s steps(60) infinite;
		}

		.dotted {
			width: 20px;
			height: 20px;
			background-color: #000;
			position: absolute;
			left: 50%;
			top: 50%;
			margin: -10px 0 0 -10px;
			border-radius: 50%;
		}

		/*动画序列*/
		@keyframes move {
			0% {
				transform: rotate(0deg);
			}

			100% {
				transform: rotate(360deg);
			}
		}
	</style>
</head>
<body>
	<div class="clock">
		<div class="line line1"></div>
		<div class="line line2"></div>
		<div class="line line3"></div>
		<div class="line line4"></div>
		<div class="line line5"></div>
		<div class="line line6"></div>
		<div class="cover"></div>
		<div class="hour"></div>
		<div class="minutes"></div>
		<div class="seconds"></div>
		<div class="dotted"></div>
	</div>
</body>
</html>`