Проблема в том, что, не рискуя, мы рискуем в сто раз больше.
22-ноября-2023, 21:31 5 0
В продолжении новогодней темы предлагаю ещё одно оформление для сайта, новогоднюю елку с шарами на CSS. Для изменения размера нужно использовать transform: scale().
HTML
<div class="merry-xmas">
<div class="star-container">
<div class="star"></div>
</div>
<div class="xmas-tree">
<div class="tree1"></div>
<div class="tree2"></div>
<div class="tree3"></div>
<div class="tree4"></div>
<div class="tree5"></div>
<div class="trunk"></div>
</div>
<div class="ornament-container1">
<div class="ornament"></div>
</div>
<div class="ornament-container2">
<div class="ornament"></div>
</div>
<div class="ornament-container3">
<div class="ornament"></div>
</div>
<div class="ornament-container4">
<div class="ornament"></div>
</div>
<div class="ornament-container5">
<div class="ornament"></div>
</div>
<div class="ornament-container6">
<div class="ornament"></div>
</div>
<div class="xmas-lights">
<div class="light1"></div>
<div class="light2"></div>
<div class="light3"></div>
<div class="light4"></div>
<div class="light5"></div>
<div class="light6"></div>
<div class="light7"></div>
<div class="light8"></div>
<div class="light9"></div>
<div class="light10"></div>
<div class="light11"></div>
<div class="light12"></div>
<div class="light13"></div>
<div class="light14"></div>
<div class="light15"></div>
<div class="light16"></div>
<div class="light17"></div>
<div class="light18"></div>
<div class="light19"></div>
<div class="light20"></div>
</div>
</div>
CSS
.merry-xmas {
margin: 0 auto 10px auto;
width: 400px;
height: 400px;
position: relative;
overflow: hidden;
}
[class^="tree"] {
position: relative;
width: 0;
height: 0;
border-style: solid;
border-radius: 100%;
}
.tree1 {
margin-left: 100px;
border-width: 0 100px 75px 100px;
border-color: transparent transparent #99c671 transparent;
z-index: 5;
}
.tree2 {
top: -40px;
margin-left: 75px;
border-width: 0 125px 85px 125px;
border-color: transparent transparent #68bb47 transparent;
z-index: 4;
}
.tree3 {
top: -85px;
margin-left: 50px;
border-width: 0 150px 100px 150px;
border-color: transparent transparent #42aa47 transparent;
z-index: 3;
}
.tree4 {
top: -140px;
margin-left: 25px;
border-width: 0 175px 115px 175px;
border-color: transparent transparent #2e9343 transparent;
z-index: 2;
}
.tree5 {
top: -215px;
border-width: 0 200px 135px 200px;
border-color: transparent transparent #247e37 transparent;
z-index: 1;
}
.trunk {
position: absolute;
width: 30px;
height: 50px;
margin-left: 185px;
top: 340px;
background-color: #996633;
}
@keyframes roty {
0% {
transform: scale(1);
}
50% {
transform: scale(1.3);
}
100% {
transform: scale(1);
}
}
.star-container {
position: relative;
height: 50px;
width: 50px;
margin-left: 195px;
top: 0px;
z-index: 6;
transform: rotate(35deg);
}
.star {
margin: 50px 0;
position: absolute;
width: 0px;
height: 0px;
border-style: solid;
border-width: 0 25px 17px 25px;
border-color: transparent transparent #ffd105 transparent;
animation: 1s roty infinite linear;
}
.star:before {
position: absolute;
height: 0;
width: 0;
top: 0px;
left: -25px;
content: '';
border-style: solid;
border-width: 0 25px 17px 25px;
border-color: transparent transparent #ffd105 transparent;
transform: rotate(-70deg);
}
.star:after {
position: absolute;
height: 0;
width: 0;
top: -12px;
left: -16px;
content: '';
border-style: solid;
border-width: 0 10px 20px 10px;
border-color: transparent transparent #ffd105 transparent;
transform: rotate(-35deg);
}
.ornament {
position: relative;
background: radial-gradient(#ffffff, #ffff99, #ffcc33);
width: 32px;
height: 32px;
border-radius: 100%;
z-index: 1;
overflow: hidden;
}
.ornament:before {
position: absolute;
content: '';
width: 20px;
height: 20px;
top: 0px;
left: 0px;
background: #fff;
border-radius: 100%;
}
.ornament:after {
position: absolute;
content: '';
width: 42px;
height: 42px;
top: -20px;
left: -10px;
border: solid 5px #ffcc33;
border-radius: 100%;
}
[class^="ornament-container"] {
position: absolute;
z-index: 7;
}
.ornament-container1 {
top: 155px;
left: 120px;
}
.ornament-container2 {
top: 210px;
left: 270px;
}
.ornament-container3 {
top: 300px;
left: 100px;
}
.ornament-container4 {
top: 110px;
left: 250px;
}
.ornament-container5 {
top: 320px;
left: 310px;
}
.ornament-container6 {
top: 250px;
left: 190px;
}
[class^="light"] {
position: absolute;
width: 5px;
height: 5px;
border-radius: 100%;
transition-property: background;
transition-duration: 1s;
transition-timing-function: linear;
animation: light 5s infinite;
z-index: 6;
}
@keyframes light {
0% {background:transparent;}
50% {background:#ffffff;}
100% {background:transparent;}
}
.xmas-lights {
position: absolute;
top:-50px;
left: -15px;
z-index: 6;
}
.light1 {
top: 150px;
left: 180px;
}
.light2 {
top: 130px;
left: 210px;
animation-delay: 3s;
}
.light3 {
top: 200px;
left: 150px;
animation-delay: 2s;
}
.light4 {
top: 210px;
left: 220px;
animation-delay: 1s;
}
.light5 {
top: 260px;
left: 180px;
animation-delay: 3s;
}
.light6 {
top: 240px;
left: 150px;
animation-delay: 2s;
}
.light7 {
top: 250px;
left: 270px;
animation-delay: 1s;
}
.light8 {
top: 300px;
left: 280px;
animation-delay: 3s;
}
.light9 {
top: 300px;
left: 200px;
animation-delay: 2s;
}
.light10 {
top: 160px;
left: 240px;
animation-delay: 1s;
}
.light11 {
top: 350px;
left: 180px;
animation-delay: 2s;
}
.light12 {
top: 3150px;
left: 210px;
animation-delay: 3s;
}
.light13 {
top: 370px;
left: 120px;
animation-delay: 2s;
}
.light14 {
top: 290px;
left: 220px;
animation-delay: 1s;
}
.light15 {
top: 320px;
left: 150px;
animation-delay: 3s;
}
.light16 {
top: 370px;
left: 200px;
animation-delay: 2s;
}
.light17 {
top: 290px;
left: 220px;
animation-delay: 1s;
}
.light18 {
top: 320px;
left: 260px;
animation-delay: 3s;
}
.light19 {
top: 370px;
left: 300px;
animation-delay: 3s;
}
.light20 {
top: 350px;
left: 250px;
animation-delay: 3s;
}