送你一朵小紅花,愿你勇敢的面對生活中的苦難,不要放棄愛與希望,藍天白云,定會如期而至,
視頻:
B站視頻鏈接:https://www.bilibili.com/video/BV1xX4y1M7yM
送你一朵小紅花,CSS實作一朵旋轉的小紅花
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>送你一朵小紅花:公眾號AlbertYang</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- 容器 -->
<div class="box">
<!-- 花朵 -->
<div class="flower">
<!-- 花瓣 -->
<div class="petal" style="--x:0"></div>
<div class="petal" style="--x:1"></div>
<div class="petal" style="--x:2"></div>
<div class="petal" style="--x:3"></div>
<div class="petal" style="--x:4"></div>
<div class="petal" style="--x:5"></div>
<!-- 花心 -->
<div class="circle"></div>
</div>
</div>
</body>
</html>
CSS
/* 清除瀏覽器設定的默認邊距,
使邊框和內邊距的值包含在元素的width和height內 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 使用flex布局,讓內容垂直和水平居中 */
.box {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
/* 花朵 */
.flower {
position: relative;
width: 80px;
height: 80px;
transform-origin: 100% 100%;
animation: rotate 3s linear infinite;
}
/* 花瓣 */
.petal {
display: block;
/* 花瓣的寬高等于花朵的寬高 */
width: 80px;
height: 80px;
background: red;
border-radius: 0 70px;
position: absolute;
/* 讓不同的花瓣旋轉為花朵 */
transform-origin: 100% 100%;
transform: rotate(calc(var(--x) * 60deg));
}
/* 花心 */
.circle {
width: 100px;
height: 100px;
position: absolute;
background: #fff200;
border-radius: 50%;
left: 30px;
top: 30px;
box-shadow: 0 0 50px yellow;
background-image: radial-gradient(at 20% 30%, #fffa65, #f1c40f, #f1dc4b);
}
/* 花朵旋轉影片 */
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

今天的學習就到這里了,由于本人能力和知識有限,如果有寫的不對的地方,還請各位大佬批評指正,有什么不明白的地方歡迎給我留言,如果想繼續學習提高,歡迎關注我,每天進步一點點,就是領先的開始,加油,如果覺得本文對你有幫助的話,歡迎轉發,評論,點贊!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/245693.html
標籤:其他
上一篇:C++物件大小,你真的知道嗎?
