还有二十多天就国庆了,给大家分享一个CSS纯前端绘制国旗的过程 🇨🇳
<div class="big-start"></div>
.big-start {
position: relative;
width: 0;
height: 0;
top: 120px;
left: 60px;
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid #FFEC73;
}
<div class="big-start"></div>
.big-start {
position: relative;
width: 0;
height: 0;
top: 120px;
left: 60px;
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid #FFEC73;
&::before {
position: absolute;
width: 0;
height: 0;
content: "";
border-right: 24px solid transparent;
border-left: 24px solid transparent;
border-bottom: 64px solid red;
}
&::after {
position: absolute;
width: 0;
height: 0;
content: "";
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid blue;
}
}
<div class="big-start"></div>
.big-start {
position: relative;
width: 0;
height: 0;
top: 120px;
left: 60px;
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid #FFEC73;
&::before {
position: absolute;
width: 0;
height: 0;
top: -44px;
left: -54px;
content: "";
border-right: 24px solid transparent;
border-left: 24px solid transparent;
border-bottom: 64px solid red;
transform: rotate(-35deg);
}
&::after {
position: absolute;
width: 0;
height: 0;
top: 3px;
left: -85px;
content: "";
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid blue;
transform: rotate(-70deg);
}
}
<div class="five-start-red-flag"></div>
.five-start-red-flag {
--flag-color: red;
width: 780px;
height: 520px;
margin: 5% auto auto;
background-color: var(--flag-color);
}
<div class="five-start-red-flag">
<div class="big-start"></div>
<div class="samll-start-1"></div>
<div class="samll-start-2"></div>
<div class="samll-start-3"></div>
<div class="samll-start-4"></div>
</div>
.five-start-red-flag {
--start-color: #FFEC73;
--flag-color: red;
position: relative;
width: 780px;
height: 520px;
margin: 5% auto auto;
background-color: var(--flag-color);
.big-start {
position: relative;
width: 0;
height: 0;
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid var(--start-color);
&::before {
position: absolute;
width: 0;
height: 0;
top: -44px;
left: -54px;
content: "";
border-right: 24px solid transparent;
border-left: 24px solid transparent;
border-bottom: 64px solid var(--start-color);
transform: rotate(-35deg);
}
&::after {
position: absolute;
width: 0;
height: 0;
top: 3px;
left: -85px;
content: "";
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid var(--start-color);
transform: rotate(-70deg);
}
transform: rotate(35deg);
}
.samll-start-1, .samll-start-2, .samll-start-3, .samll-start-4 {
position: relative;
width: 0;
height: 0;
top: -10px;
left: 260px;
border-right: 26px solid transparent;
border-left: 26px solid transparent;
border-bottom: 18px solid var(--start-color);
&::before {
position: absolute;
width: 0;
height: 0;
top: -12px;
left: -17px;
content: "";
border-right: 8px solid transparent;
border-left: 8px solid transparent;
border-bottom: 21px solid var(--start-color);
transform: rotate(-35deg);
}
&::after {
position: absolute;
width: 0;
height: 0;
top: 1px;
left: -27px;
content: "";
border-right: 26px solid transparent;
border-left: 26px solid transparent;
border-bottom: 18px solid var(--start-color);
transform: rotate(-70deg);
}
}
}
.five-start-red-flag {
--start-color: #FFEC73;
--flag-color: red;
position: relative;
width: 780px;
height: 520px;
margin: 5% auto auto;
background-color: var(--flag-color);
.big-start {
position: relative;
width: 0;
height: 0;
top: 120px;
left: 60px;
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid var(--start-color);
&::before {
position: absolute;
width: 0;
height: 0;
top: -44px;
left: -54px;
content: "";
border-right: 24px solid transparent;
border-left: 24px solid transparent;
border-bottom: 64px solid var(--start-color);
transform: rotate(-35deg);
}
&::after {
position: absolute;
width: 0;
height: 0;
top: 3px;
left: -85px;
content: "";
border-right: 80px solid transparent;
border-left: 80px solid transparent;
border-bottom: 56px solid var(--start-color);
transform: rotate(-70deg);
}
transform: rotate(35deg);
}
.samll-start-1, .samll-start-2, .samll-start-3, .samll-start-4 {
position: relative;
width: 0;
height: 0;
top: -10px;
left: 260px;
border-right: 26px solid transparent;
border-left: 26px solid transparent;
border-bottom: 18px solid var(--start-color);
&::before {
position: absolute;
width: 0;
height: 0;
top: -12px;
left: -17px;
content: "";
border-right: 8px solid transparent;
border-left: 8px solid transparent;
border-bottom: 21px solid var(--start-color);
transform: rotate(-35deg);
}
&::after {
position: absolute;
width: 0;
height: 0;
top: 1px;
left: -27px;
content: "";
border-right: 26px solid transparent;
border-left: 26px solid transparent;
border-bottom: 18px solid var(--start-color);
transform: rotate(-70deg);
}
}
.samll-start-1 {
transform: rotate(-20deg);
}
.samll-start-2 {
top: 35px;
left: 320px;
transform: rotate(10deg)
}
.samll-start-3 {
top: 100px;
left: 320px;
transform: rotate(30deg);
}
.samll-start-4 {
top: 140px;
transform: rotate(45deg);
}
}
您的鼓励(点赞、关注、收藏)是我持续创作的动力,如果对你有帮助,支持一下,Thanks♪(・ω・)ノ 🇨🇳