纯css布局实现一个狗狗的家
代码语言:html
所属分类:布局界面
代码描述:纯css布局实现一个狗狗的家
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
html,
body {
width: 100%;
height: 100%;
background-color: #f9ccca;
transform: translate3d(0, 0, 0) scale(0.85);
animation: zoom 10s ease forwards;
}
@keyframes zoom {
100% {
transform: scale(0.9);
}
}
.container {
width: 100%;
height: 100%;
background-color: #f9ccca;
display: grid;
place-content: center;
}
.switch-container {
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
}
.land {
transform: rotate(-25deg) skew(25deg) scale(0.8);
position: absolute;
border-radius: 20px;
}
.path {
width: 450px;
height: 100px;
background-color: #ffe5b9;
top: 18px;
left: 60px;
}
.path:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background-color: #ffe5b9;
left: 300px;
top: -15px;
}
.grass {
width: 650px;
height: 400px;
left: -100px;
background-color: #94dad0;
top: -40px;
border: 1px solid black;
}
.grass:before {
content: "";
position: absolute;
border-radius: 20px;
background-color: #94dad0;
width: 150px;
height: 150px;
left: 600px;
top: 30px;
border: 1px solid black;
}
.grass:after {
content: "";
position: absolute;
border-radius: 20px;
background-color: #94dad0;
width: 450px;
height: 150px;
left: 100px;
top: -50px;
border-top: 1px solid black;
}
.sand {
background-color: #fff8ec;
width: 300px;
height: 220px;
bottom: -100px;
left: 180px;
box-shadow: inset 10px 1px 20px #ffdca0, -2px 2px #ffd286, inset -10px 1px 20px #ffdca0, 2px 2px #ffad20;
}
.sand:before, .sand:after {
position: absolute;
content: "";
background-color: #fff8ec;
}
.sand:before {
width: 150px;
height: 80px;
bottom: -50px;
right: 0;
border-radius: 20px;
box-shadow: inset -10px -12px 20px #ffdca0, -2px 2px #ffd286, inset 5px -12px 20px #ffdca0, -2px 2px #ffad20, 2px 2px #ffad20;
}
.sand:after {
width: 130px;
height: 55px;
bottom: 4px;
right: 22px;
clip-path: polygon(0 0, 100% 0, 100% 99%, 18% 100%, 0 90%);
}
.water {
width: 350px;
height: 150px;
background-color: #2bc0e4;
background-image: linear-gradient(to top, #5b86e5, #83f7ff 70%);
background-size: 350px 900px;
box-shadow: inset -5px -5px 30px #00c3e3;
bottom: 0;
left: 445px;
animation: animateLakeColor 10s infinite;
overflow: hidden;
}
.bubbles {
position: absolute;
width: 70px;
height: 20px;
left: 630px;
top: 335px;
transform: rotate(-30deg);
}
.bubbles .bubble {
position: absolute;
display: inline-block;
background-color: white;
border-radius: 100%;
width: 100%;
}
.bubbles .bubble:nth-child(1) {
width: 24px;
height: 24px;
left: -5px;
animation: scaleBubble 2s 1.2s linear infinite;
}
.bubbles .bubble:nth-child(2) {
width: 36px;
height: 36px;
left: 0px;
animation: scaleBubble 3s 1.2s linear infinite;
}
.bubbles .bubble:nth-child(3) {
width: 30px;
height: 30px;
left: 5px;
animation: scaleBubble 2s 1.2s linear infinite;
}
.bubbles .bubble:nth-child(4) {
width: 24px;
height: 24px;
left: 10px;
animation: scaleBubble 2s 0.2s linear infinite;
}
.bubbles .bubble:nth-child(5) {
width: 32px;
height: 32px;
left: 15px;
animation: scaleBubble 3s 0.2s linear infinite;
}
.bubbles .bubble:nth-child(6) {
width: 27px;
height: 27px;
left: 20px;
animation: scaleBubble 3s 0.2s linear infinite;
}
.bubbles .bubble:nth-child(7) {
width: 39px;
height: 39px;
left: 25px;
animation: scaleBubble 1s 0.2s linear infinite;
}
.bubbles .bubble:nth-child(8) {
width: 34px;
height: 34px;
left: 30px;
animation: scaleBubble 2s 1.2s linear infinite;
}
.bubbles .bubble:nth-child(9) {
width: 35px;
height: 35px;
left: 35px;
animation: scaleBubble 2s 1.2s linear infinite;
}
.bubbles .bubble:nth-child(10) {
width: 46px;
height: 46px;
left: 40px;
animation: scaleBubble 1s 0.2s linear infinite;
}
@keyframes scaleBubble {
50% {
transform: scale(0.5);
}
}
@keyframes animateLakeColor {
50% {
background-position-y: -200px;
}
}
.switch-base {
position: relative;
width: 680px;
height: 300px;
background-color: #1d1d1d;
border-radius: 30px;
top: 30px;
transform: rotate(-25deg) skew(25deg) scale(0.8);
display: grid;
grid-template-columns: 1fr 5fr 1fr;
overflow: hidden;
}
.switch-base .joycon-shadow-blue {
width: 100%;
height: 100%;
background-color: #0097b0;
}
.switch-base .joycon-shadow-red {
width: 100%;
height: 100%;
background-color: #ff1225;
}
.joycon-blue-base {
position: absolute;
width: 20px;
height: 30px;
background-color: #0097b0;
left: 4px;
top: 185px;
}
.joycon-blue-base:after {
content: "";
position: absolute;
width: 25px;
height: 33px;
background-color: #0097b0;
left: 236px;
top: 130px;
z-index: 1;
}
.black-base {
position: absolute;
width: 30px;
height: 33px;
background-color: #1d1d1d;
left: 587px;
top: 150px;
z-index: 1;
}
.black-base:after {
position: absolute;
content: "";
width: 50px;
height: 55px;
background-color: #83f7ff;
right: 17px;
top: 10px;
}
.joycon-red-base {
position: absolute;
width: 20px;
height: 30px;
background-color: #ff1225;
left: 656px;
top: 120px;
z-index: 1;
}
.switch {
position: absolute;
width: 680px;
height: 300px;
background-color: #373737;
border-radius: 30px;
display: grid;
grid-template-columns: 1fr 5fr 1fr;
overflow: hidden;
transform: rotate(-25deg) skew(25deg) scale(0.8);
z-index: 2;
}
.switch .joycon {
height: 100%;
}
.switch .joycon .joystick {
position: relative;
width: 50px;
height: 50px;
left: calc(50% - 25px);
background-color: #414548;
background-image: radial-gradient(25px 25px at 55% center, #414548 30%, #1d1d1d), radial-gradient(20px 20px at 20% 50%, #1d1d1d, transparent);
border-radius: 100%;
}
.switch .joycon .buttons {
position: relative;
width: 70px;
height: 70px;
left: calc(50% - 35px);
background-image: radial-gradient(12px 12px at 50% 20%, #414548 10%, #1d1d1d 95%, 99%, transparent), radial-gradient(12px 12px at 20% 50%, #414548 10%, #1d1d1d 95%, 99%, transparent), radial-gradient(12px 12px at 80% 50%, #414548 10%, #1d1d1d 95%, 99%, transparent), radial-gradient(12px 12px at 50% 80%, #414548 10%, #1d1d1d 95%, 99%, transparent);
}
.switch .joycon.red {
background-color: #ff4554;
}
.switch .joycon.red .plus {
position: relative;
width: 7px;
height: 18px;
background-color: #1d1d1d;
left: 20%;
top: 20px;
}
.switch .joycon.red .plus:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
background-color: #1d1d1d;
transform-origin: center;
transform: rotate(90deg);
}
.switch .joycon.red .joystick {
top: 80px;
}
.switch .joycon.red .buttons {
top: 30px;
}
.switch .joycon.red .home-button {
position: relative;
width: 22px;
height: 22px;
background-color: #575757;
background-image: radial-gradient(12px 12px at center, #414548 60%, #1d1d1d 62%, transparent);
border-radius: 100%;
border: 1px solid #1d1d1d;
left: 15%;
top: 110px;
}
.switch .joycon.blue {
background-color: #00c3e3;
}
.switch .joycon.blue .joystick {
top: -20px;
}
.switch .joycon.blue .buttons {
top: 50%;
}
.switch .joycon.blue .minus {
position: relative;
width: 20px;
height: 10px;
background-color: #1d1d1d;
left: 60%;
top: 20px;
border-radius: 5px;
}
.switch .joycon.blue .capture-button {
position: relative;
width: 15px;
height: 15px;
background-color: #414548;
background-image: radial-gradient(6px 6px at center, #414548 70%, #1d1d1d 99%, transparent);
border: 2px solid #1d1d1d;
border-radius: 3px;
left: 65%;
top: 120px;
}
.switch .screen {
box-sizing: border-box;
width: 100%;
height: 100%;
border: 30px solid #2a2a2a;
background-color: #35bb87;
background-color: #61d4c5;
background-color: #94dad0;
}
.switch .screen .river {
position: relative;
background-color: #2bc0e4;
background-image: linear-gradient(to bottom, #5b86e5, #83f7ff 70%);
width: 70px;
height: 130%;
top: -30px;
left: 85%;
background-size: 300px 400px;
animation: animateWaterColor 10s infinite;
box-shadow: -10px 0px 20px #379e8f;
}
.switch .screen .river .flow-container {
width: 100%;
height: 100%;
position: absolute;
display: flex;
justify-content: space-evenly;
}
.switch .screen .river .flow-container .flow {
flex: 1 1 0px;
width: 10px;
background-color: rgba(255, 255, 255, 0.4);
border-radius: 100px;
transform: translateY(-100px);
height: 20px;
}
.switch .screen .river .flow-container .flow:nth-child(0) {
animation: flow 5s 0s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(1) {
animation: flow 5s 0.1s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(2) {
animation: flow 5s 0.2s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(3) {
animation: flow 2s 0.3s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(4) {
animation: flow 2s 0.4s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(5) {
animation: flow 5s 0.5s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(6) {
animation: flow 4s 0.6s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(7) {
animation: flow 5s 0.7s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(8) {
animation: flow 4s 0.8s linear infinite;
}
.switch .screen .river .flow-container .flow:nth-child(9) {
animation: flow 4s 0.9s linear infinite;
}
@keyframes flow {
100% {
transform: translateY(700px);
}
}
.switch .screen .river .river-row {
position: absolute;
width: 100%;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
}
.switch .screen .river .river-row .streak {
flex: 1 1 1px;
background-color: white;
border-radius: 100px;
height: 100%;
width: auto;
}
.switch .screen .river .river-row:nth-child(1) {
top: 60px;
}
.switch .screen .river .river-row:nth-child(1) > .streak:nth-child(1) {
animation: streak 3s 1s linear infinite;
}
.switch .screen .river .river-row:nth-child(1) > .streak:nth-child(2) {
animation: streak 1s 0s linear infinite;
}
.switch .screen .river .river-row:nth-child(1) > .streak:nth-child(3) {
animation: streak 3s 0s linear infinite;
}
.switch .screen .river .river-row:nth-child(1) > .streak:nth-child(4) {
animation: streak 1s 0s linear infinite;
}
.switch .screen .river .river-row:nth-child(1) > .streak:nth-child(5) {
animation: streak 3s 0s linear infinite;
}
.switch .screen .river .river-row:nth-child(1) > .streak:nth-child(6) {
animation: streak 3s 1s linear infinite;
}
.switch .screen .river .river-row:nth-child(1) > .streak:nth-child(7) {
animation: streak 1s 0s linear infinite;
}
.switch .screen .river .river-row:nth-child(2) {
top: 200px;
}
.switch .screen .river .river-row:nth-child(2) > .streak:nth-child(1) {
animation: streak 2s 0s linear infinite;
}
.switch .screen .river .river-row:nth-child(2) > .streak:nth-child(2) {
animation: streak 2s 0s linear infinite;
}
.switch .screen .river .river-row:nth-child(2) > .streak:nth-child(3) {
animation: streak 3s 1s linear infinite;
}
.switch .screen .river .river-row:nth-child(2) > .streak:nth-child(4) {
animation: streak 3s 1s linear infinite;
}
.switch .screen .river .river-row:nth-child(2) > .streak:nth-child(5) {
animation: streak 3s 1s linear infinite;
}
.switch .screen .river .river-row:nth-child(2) > .streak:nth-child(6) {
animation: streak 1s 1s linear infinite;
}
.switch .screen .river .river-row:nth-child(2) > .streak:nth-child(7) {
animation: streak 3s 1s linear infin.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0