div+css布局实现日落风景效果代码
代码语言:html
所属分类:布局界面
代码描述:div+css布局实现日落风景效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --clr-black: rgba(50, 50, 50, 255); --clr-sun: rgba(246, 243, 198, 255); --gradient-bg: linear-gradient( 180deg, rgba(241, 80, 150, 1) 0%, rgba(228, 151, 109, 1) 50% ); --clr-white: rgba(254, 250, 239, 255); --clr-mountain1: rgba(105, 96, 101, 255); --clr-mountain2: rgba(140, 138, 160, 255); } *, *::after, *::before { margin: 0; padding: 0; box-sizing: border-box; } body { min-height: 100vh; overflow: hidden; } .sky { height: 65vh; width: 100%; background: var(--gradient-bg); } .front { display: flex; position: absolute; bottom: 0; height: 50vh; width: 100%; z-index: 999; } .left-slope, .right-slope { flex: 1; height: 150%; background-color: var(--clr-black); } .left-slope { transform: skewY(5deg); } .right-slope { transform: skewY(-5deg); } .mountain1 > .left, .mountain1 > .right { position: absolute; height: 25vmin; top: 20vmin; width: 55vmin; background-color: var(--clr-mountain1); } .mountain1 > .left { transform-origin: left top; transform: rotate(35deg); } .mountain1 > .right { right: 0; transform-origin: right top; transform: rotate(-35deg); } .mountain2 > .left, .mountain2 > .right { position: absolute; height: 10vmin; top: 25vmin; width: 90vmin; background-color: var(--clr-mountain2); } .mountain2 > .left { transform-origin: left top; transform: rotate(19deg); } .mountain2 > .right { right: 0; transform-origin: right top; transform: rotate(-19deg); } .sun { height: 55vmin; aspect-ratio: 1; position: absolute; left: 50%; top: 40%; background-color: var(--clr-sun); border-radius: 50%; transform: translate(-50%, -40%); box-shadow: 0 0 0 2.5vmin rgba(246, 243, 198, 0.1), 0 0 0 5vmin rgba(246, 243, 198, 0.1); } .trees { position: absolute; width: 100%; } .tree { position: absolute; bottom: 0; display: inline-block; width: 0; height: 0; border-style: solid; border-color: transparent transparent var(--clr-black) transparent; } .tree-big { border-width: 0 10vmin 25vmin 10vmin; } .tree-small { border-width: 0 5vmin 15vmin 5vmin; } .tree-mid { border-width: 0 8vmin 18vmin 8vmin; } .tree:nth-child(1) { left: 1vmin; } .tree:nth-child(2) { left: 7vmin; } .tree:nth-child(3) { left: 30vmin; transform: translateY(5vmin); } .tree:nth-child(4) { left: 35vmin; transform: translateY(5vmin); } .tree:nth-child(5) { left: 47vmin; transform: translateY(5vmin) scaleX(0.8); } .tree:nth-child(6) { left: 70vmin; transform: translateY(8vmin) scaleX(0.8); } .tree:nth-child(7) { left: 80vmin; transform: translateY(10vmin); } .tree:nth-child(8) { left: 87vmin; transform: translateY(10vmin) scaleX(0.6); } .tree:nth-child(9) { left: 110vmin; transform: translateY(10vmin) scaleX(0.8); } .tree:nth-child(10) { left: 120vmin; transform: translateY(5vmin) scaleX(0.6); } .tree:nth-child(11) { left: 125vmin; transform: translateY(7vmin) scaleX(0.6); } .tree:nth-child(12) { left: 135vmin; transform: translateY(8vmin) scaleX(0.8); } .tree:nth-child(13) { left: 145vmin; transform: translateY(6vmin) scaleX(0.8); } .tree:nth-child(14) { left: 155vmin; transform: translateY(3vmin) scaleX(0.8); } .tree:nth-child(15) { left: 158vmin; transform: translateY(5vmin) scaleX(0.8); } .tree:nth-child(16) { left: 175vmin; transform: translateY(3vmin) scaleX(0.8); } .tree:nth-child(17) { left: 180vmin; transform: translateY(5vmin) scaleX(0.........完整代码请登录后点击上方下载按钮下载查看
网友评论0