本页面中的按钮是在网上找的,感觉十分好看,变收藏了,侵权立删
这次算是一个启发吧,以后实现点一下换一个主题
废话不说了,上图
第一个按钮是经典布局,第二个是小清新,第三个是时尚
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标签页</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
background: #e0e5ec;
}
h1 {
position: relative;
text-align: center;
color: #353535;
font-size: 50px;
font-family: "Cormorant Garamond", serif;
}
p {
font-family: 'Lato', sans-serif;
font-weight: 300;
text-align: center;
font-size: 18px;
color: #676767;
}
.custom-btn {
width: 130px;
height: 40px;
color: #fff;
border-radius: 5px;
padding: 10px 25px;
font-family: 'Lato', sans-serif;
font-weight: 500;
background: transparent;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
display: inline-block;
box-shadow: inset 2px 2px 2px 0px rgba(255, 255, 255, .5),
7px 7px 20px 0px rgba(0, 0, 0, .1),
4px 4px 5px 0px rgba(0, 0, 0, .1);
outline: none;
}
/* 6 */
.btn-6 {
background: rgb(247, 150, 192);
background: radial-gradient(circle, rgba(247, 150, 192, 1) 0%, rgba(118, 174, 241, 1) 100%);
line-height: 42px;
padding: 0;
border: none;
}
.btn-6 span {
position: relative;
display: block;
width: 100%;
height: 100%;
}
.btn-6:before,
.btn-6:after {
position: absolute;
content: "";
height: 0%;
width: 1px;
box-shadow:
-1px -1px 20px 0px rgba(255, 255, 255, 1),
-4px -4px 5px 0px rgba(255, 255, 255, 1),
7px 7px 20px 0px rgba(0, 0, 0, .4),
4px 4px 5px 0px rgba(0, 0, 0, .3);
}
.btn-6:before {
right: 0;
top: 0;
transition: all 500ms ease;
}
.btn-6:after {
left: 0;
bottom: 0;
transition: all 500ms ease;
}
.btn-6:hover {
background: transparent;
color: #76aef1;
box-shadow: none;
}
.btn-6:hover:before {
transition: all 500ms ease;
height: 100%;
}
.btn-6:hover:after {
transition: all 500ms ease;
height: 100%;
}
.btn-6 span:before,
.btn-6 span:after {
position: absolute;
content: "";
box-shadow:
-1px -1px 20px 0px rgba(255, 255, 255, 1),
-4px -4px 5px 0px rgba(255, 255, 255, 1),
7px 7px 20px 0px rgba(0, 0, 0, .4),
4px 4px 5px 0px rgba(0, 0, 0, .3);
}
.btn-6 span:before {
left: 0;
top: 0;
width: 0%;
height: .5px;
transition: all 500ms ease;
}
.btn-6 span:after {
right: 0;
bottom: 0;
width: 0%;
height: .5px;
transition: all 500ms ease;
}
.btn-6 span:hover:before {
width: 100%;
}
.btn-6 span:hover:after {
width: 100%;
}
/* 9 */
.btn-9 {
border: none;
transition: all 0.3s ease;
overflow: hidden;
}
.btn-9:after {
position: absolute;
content: " ";
z-index: -1;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #1fd1f9;
background-image: linear-gradient(315deg, #1fd1f9 0%, #b621fe 74%);
transition: all 0.3s ease;
}
.btn-9:hover {
background: transparent;
box-shadow: 4px 4px 6px 0 rgba(255, 255, 255, .5),
-4px -4px 6px 0 rgba(116, 125, 136, .2),
inset -4px -4px 6px 0 rgba(255, 255, 255, .5),
inset 4px 4px 6px 0 rgba(116, 125, 136, .3);
color: #fff;
}
.btn-9:hover:after {
-webkit-transform: scale(2) rotate(180deg);
transform: scale(2) rotate(180deg);
box-shadow: 4px 4px 6px 0 rgba(255, 255, 255, .5),
-4px -4px 6px 0 rgba(116, 125, 136, .2),
inset -4px -4px 6px 0 rgba(255, 255, 255, .5),
inset 4px 4px 6px 0 rgba(116, 125, 136, .3);
}
/* 12 */
.btn-12 {
position: relative;
right: 20px;
bottom: 20px;
border: none;
box-shadow: none;
width: 130px;
height: 40px;
line-height: 42px;
-webkit-perspective: 230px;
perspective: 230px;
}
.btn-12 span {
background: rgb(0, 172, 238);
background: linear-gradient(0deg, rgba(0, 172, 238, 1) 0%, rgba(2, 126, 251, 1) 100%);
display: block;
position: absolute;
width: 130px;
height: 40px;
box-shadow: inset 2px 2px 2px 0px rgba(255, 255, 255, .5),
7px 7px 20px 0px rgba(0, 0, 0, .1),
4px 4px 5px 0px rgba(0, 0, 0, .1);
border-radius: 5px;
margin: 0;
text-align: center;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all .3s;
transition: all .3s;
}
.btn-12 span:nth-child(1) {
box-shadow:
-7px -7px 20px 0px #fff9,
-4px -4px 5px 0px #fff9,
7px 7px 20px 0px #0002,
4px 4px 5px 0px #0001;
-webkit-transform: rotateX(90deg);
-moz-transform: rotateX(90deg);
transform: rotateX(90deg);
-webkit-transform-origin: 50% 50% -20px;
-moz-transform-origin: 50% 50% -20px;
transform-origin: 50% 50% -20px;
}
.btn-12 span:nth-child(2) {
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
transform: rotateX(0deg);
-webkit-transform-origin: 50% 50% -20px;
-moz-transform-origin: 50% 50% -20px;
transform-origin: 50% 50% -20px;
}
.btn-12:hover span:nth-child(1) {
box-shadow: inset 2px 2px 2px 0px rgba(255, 255, 255, .5),
7px 7px 20px 0px rgba(0, 0, 0, .1),
4px 4px 5px 0px rgba(0, 0, 0, .1);
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
transform: rotateX(0deg);
}
.btn-12:hover span:nth-child(2) {
box-shadow: inset 2px 2px 2px 0px rgba(255, 255, 255, .5),
7px 7px 20px 0px rgba(0, 0, 0, .1),
4px 4px 5px 0px rgba(0, 0, 0, .1);
color: transparent;
-webkit-transform: rotateX(-90deg);
-moz-transform: rotateX(-90deg);
transform: rotateX(-90deg);
}
.containerOne {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.menu {
width: 30%;
display: flex;
justify-content: space-around;
margin: 40px 0;
}
#template {
width: 80%;
display: grid;
grid-template-columns: repeat(4, 1fr);
/* grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); */
grid-template-rows: repeat(7, 80px);
gap: 20px;
}
#template div {
background-color: rgb(131, 202, 250);
color: rgb(255, 255, 255);
font-size: 34px;
display: flex;
align-items: center;
justify-content: center;
}
#template div:nth-child(1) {
grid-column: 1/span 4;
}
#template div:nth-child(18) {
grid-column: 1/5;
/* grid-area: footer; */
}
</style>
</head>
<body>
<h1>Animation Mould</h1>
<p>Please choose the style you like!</p>
<div class="containerOne">
<div class="menu">
<button class="custom-btn btn-6"><span>classics</span></button>
<button class="custom-btn btn-12"><span>Click!</span><span>fresh</span></button>
<button class="custom-btn btn-9">fashion</button>
</div>
<div id="template">
<div class="item">header</div>
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
<div class="item">10</div>
<div class="item">11</div>
<div class="item">12</div>
<div class="item">13</div>
<div class="item">14</div>
<div class="item">15</div>
<div class="item">16</div>
<div class="item">footer</div>
</div>
</div>
</body>
<script>
let btnLisy = document.querySelectorAll("button");
let temPlate = document.getElementById("template");
let items = document.querySelectorAll(".item");//#temPlate > div调查为什么不行
btnLisy[1].onclick = function () {
initializeFun();
for (let i = 1; i < 15; i++) {
items[i].style.display = "none";
}
items[15].innerHTML = "leftContent";
items[15].style.gridColumn = "1/span 1";
items[15].style.gridRow = "2/span 3";
items[16].innerHTML = "mainContent";
items[16].style.gridColumn = "2/span 3";
items[16].style.gridRow = "2/span 3";
}
btnLisy[0].onclick = function () {
initializeFun();
}
btnLisy[2].onclick = function () {
initializeFun();
for (let i = 1; i < 13; i++) {
items[i].style.display = "none";
}
items[13].innerHTML = "leftContent";
items[13].style.gridColumn = "1/span 1";
items[13].style.gridRow = "2/span 3";
items[14].innerHTML = "mainContent";
items[14].style.gridColumn = "2/span 2";
items[14].style.gridRow = "2/span 3";
items[15].innerHTML = "rightContent";
items[15].style.gridColumn = "4/span 1";
items[15].style.gridRow = "2/span 3";
items[16].innerHTML = "secondaryContent";
items[16].style.gridColumn = "1/span 4";
items[16].style.gridRow = "5/span 1";
}
function initializeFun() {
for (let i = 1; i < 15; i++) {
items[i].style.display = "flex";
}
items[13].innerHTML = "13";
items[13].style.gridColumn = "";
items[13].style.gridRow = "";
items[14].innerHTML = "14";
items[14].style.gridColumn = "";
items[14].style.gridRow = "3";
items[15].innerHTML = "15";
items[15].style.gridColumn = "";
items[15].style.gridRow = "";
items[16].innerHTML = "16";
items[16].style.gridColumn = "";
items[16].style.gridRow = "";
}
</script>
</html>