随着现代网页设计的不断进步,CSS3 已经成为了网页设计的一个重要工具。在这个现代化的时代,大家可以通过 CSS3 来制作各种各样的网页设计,其中包括灯笼亮灯。
灯笼亮灯是一个有趣的网页设计,它由 HTML 和 CSS3 组成。大家可以使用 CSS3 来控制灯笼的样式和灯光的亮度。下面大家将介绍如何使用 CSS3 制作灯笼亮灯。
让大家首先创建一个灯笼的 HTML 代码。在这个灯笼的 HTML 代码中,大家将使用 CSS3 来改变灯笼的外观和灯光的亮度。
“`html
<!DOCTYPE html>
<html>
<head>
<title>灯笼亮灯</title>
<style>
.灯笼 {
position: relative;
width: 100px;
height: 100px;
background-size: cover;
background-position: center;
cursor: pointer;
}
.灯笼:hover {
background-size: cover;
background-position: center;
}
.灯笼__inner {
position: absolute;
width: 50px;
height: 50px;
background-color: #f00;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
.灯笼__inner:before,
.灯笼__inner:after {
content: “”;
position: absolute;
top: 0;
left: 50px;
width: 0;
height: 0;
border-radius: 50%;
background-color: #fff;
transform: rotate(-45deg);
transform-origin: 100% 100%;
}
.灯笼__inner:after {
left: 0;
transform: rotate(45deg);
transform-origin: 0 100%;
}
.灯笼__灯笼 {
position: absolute;
width: 100px;
height: 100px;
background-size: cover;
background-position: center;
cursor: pointer;
}
.灯笼__灯笼:hover {
background-size: cover;
background-position: center;
}
.灯笼__灯笼__inner {
position: absolute;
width: 50px;
height: 50px;
background-color: #f00;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
.灯笼__灯笼__inner:before,
.灯笼__灯笼__inner:after {
content: “”;
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
border-radius: 0 0 50% 50%;
background-color: #fff;
transform: scale(0.5);
transform-origin: 0 100%;
}
.灯笼__灯笼__inner:after {
left: 0;
transform: scale(1);
transform-origin: 100% 100%;
}
</style>
</head>
<body>
<div class=”灯笼”>
<div class=”灯笼__inner”></div>
<div class=”灯笼__inner”></div>
<div class=”灯笼__inner”></div>
</div>
<script>
// 样式表
const灯笼 = document.querySelector(‘.灯笼’);
灯笼.classList.add(‘灯笼-hover’);
const灯笼__inner = document.querySelector(‘.灯笼__inner’);
灯笼__inner.classList.add(‘灯笼-hover’);
const灯笼__灯笼 = document.querySelector(‘.灯笼__灯笼’);
灯笼__灯笼.classList.add(‘灯笼-hover’);
// 代码
const div = document.createElement(‘div’);
div.classList.add(‘灯笼-hover’);
const inner = document.createElement(‘div’);
inner.classList.add(‘灯笼-hover’);
const灯笼__灯笼__inner = document.createElement(‘div’);
灯笼__灯笼__inner.classList.add(‘灯笼-hover’);
const灯笼__inner = document.createElement(‘div’);
灯笼__inner.classList.add(‘灯笼-hover’);
const div2 = document.createElement(‘div’);
div2.classList.add(‘灯笼-hover’);
const inner2 = document.createElement(‘div’);
inner2.classList.add(‘灯笼-hover’);
const灯笼__灯笼__inner2 = document.createElement(‘div’);
灯笼__灯笼__inner2.classList.add(‘灯笼-hover’);
const灯笼 = document.querySelector(‘.灯笼__灯笼’);
灯笼.appendChild(灯笼__灯笼__inner);
灯笼.appendChild(灯笼__灯笼__inner2);
灯笼.appendChild(inner2);
灯笼.appendChild(div2);
// 代码
const div3 = document.createElement(‘div’);
div3.classList.add(‘灯笼-hover’);
const inner3 = document.createElement(‘div’);
inner3.classList.add(‘灯笼-hover’);
const灯笼__灯笼__inner3 = document.createElement(‘div’);
灯笼__灯笼__inner3.classList.add(‘灯笼-hover’);
const灯笼__inner3 = document.createElement(‘div’);
灯笼__inner3.classList.add(‘灯笼-hover’);
const div4 = document.createElement(‘div’);
div4.classList.add(‘灯笼-hover’);
const inner4 = document.createElement(‘div’);
inner4.classList.add(‘灯笼-hover’);
const灯笼__灯笼__inner4 = document.createElement(‘div’);
灯笼__灯笼__inner4.classList.add(‘灯笼-hover’);
const灯笼__inner4 = document.createElement(‘div’);
灯笼__inner4.classList.add(‘灯笼-hover’);
const div5 = document.createElement(‘div’);
div5.classList.add(‘灯笼-hover’);
const inner5 = document.createElement(‘div’);
inner5.classList.add(‘灯笼-hover’);
const灯笼__灯笼__inner5 = document.createElement(‘div’);
灯笼__灯笼__inner5.classList.add(‘灯笼-hover’);
const inner6 = document.createElement(‘div’);
inner6.classList.add(‘灯笼-hover’);
const灯笼__inner6 = document.createElement(‘div’);
灯笼__inner6.classList.add(‘灯笼hover’);