html部分
···
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>triangle 三角形</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="../css/triangle.css">
<!-- <script src="main.js"></script> -->
</head>
<body>
<div class="t1"> </div>
<div class="t2"> </div>
<div class="td">向下</div>
<div class="tu">向上</div>
<div class="tl">向左</div>
<div class="tr">向右</div>
<div>-------------- 三角箭头 arrow ----------------</div>
<div class="ad"></div>
<div class="au"></div>
<div style="width:20px;height: 20px"> </div>
<div class="al"></div>
<div class="ar"></div>
</body>
</html>
···
CSS 部分
.t1 {
width: 0;
height: 0;
border: 100px solid #339933;
}
.t2 {
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: #FFCCCC #0099CC #996699 #339933;
}
/* 向下 */
.td {
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: #FFCCCC transparent transparent transparent;
}
.td:hover {
animation: t2R 1s forwards;
}
@keyframes t2R {
from {
transform: rotateZ(90deg);
transform-origin: 50% 25%;
}
to {
transform: rotateZ(180deg);
transform-origin: 50% 25%;
}
}
/* 向上 */
.tu {
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: transparent transparent #FFCCCC transparent;
}
/* 向左 */
.tl {
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: transparent #FFCCCC transparent transparent;
}
/* 向右 */
.tr {
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: transparent transparent transparent #FFCCCC;
}
/*向上*/
.au {
position: relative;
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: transparent transparent #000 transparent;
}
.au:after {
position: absolute;
z-index: 2;
bottom: -101px;
left: -100px;
content: '';
border-width: 100px;
border-style: solid;
border-color: transparent transparent #fff transparent;
}
.au:hover {
animation: auR 1s forwards;
}
@keyframes auR {
from {
transform: rotateZ(90deg);
transform-origin: 50% 75%;
}
to {
transform: rotateZ(180deg);
transform-origin: 50% 75%;
}
}
/*向下*/
.ad {
position: relative;
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: #000 transparent transparent transparent;
}
.ad:after {
position: absolute;
z-index: 2;
top: -101px;
left: -100px;
content: '';
border-width: 100px;
border-style: solid;
border-color: #fff transparent transparent transparent;
}
.ad:hover {
animation: adR 1s forwards;
}
@keyframes adR {
from {
transform: rotateZ(90deg);
transform-origin: 50% 25%;
}
to {
transform: rotateZ(180deg);
transform-origin: 50% 25%;
}
}
/* 向左 */
.al {
position: relative;
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: transparent #000 transparent transparent;
}
.al:after {
position: absolute;
width: 0;
height: 0;
left: -99px;
top: -100px;
content: '';
border-width: 100px;
border-style: solid;
border-color: transparent #fff transparent transparent;
}
.al:hover {
animation: alR 1s forwards;
}
@keyframes alR {
form {
transform: rotateZ(90deg);
transform-origin: 75% 50%;
}
to {
transform: rotateZ(180deg);
transform-origin: 75% 50%;
}
}
/* 向右 */
.ar {
position: relative;
width: 0;
height: 0;
border-width: 100px;
border-style: solid;
border-color: transparent transparent transparent #000;
}
.ar:after {
position: absolute;
width: 0;
height: 0;
left: -101px;
top: -100px;
content: '';
border-width: 100px;
border-style: solid;
border-color: transparent transparent transparent #fff;
}
.ar:hover {
animation: arR 1s forwards;
}
@keyframes arR {
from {
transform: rotateZ(90deg);
transform-origin: 25% 50%;
}
to {
transform: rotateZ(180deg);
transform-origin: 25% 50%;
}
}
网友评论