[100天挑战100个前端效果]第二十四天---群玉山头见

news/2024/7/19 14:33:30 标签: js, css, html, css3

画群山

  • 让我们先来看看实现的效果(接二十三天)
  • 设计思路与今日份知识总结
    • 设计思路
    • 知识总结

让我们先来看看实现的效果(接二十三天)

在这里插入图片描述

html_4">html代码

html"><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.html" title=css>css">
    <title>第二十四天</title>
</head>
<body>
    <div class="channel">
        switch切换按钮啦!
    </div>
    <div class="container">
        <!-- 速度切换开关 -->
        <div id="switch" >
            <div id="circle"></div>
        </div>
        <!-- 主画布 -->
        <div class="main">
            <!-- 太阳 -->
            <div class="sun">
                <!-- span[style=--i:$]*8 -->
                <span style="html" title=css>css">--i:1"></span>
                <span style="html" title=css>css">--i:2"></span>
                <span style="html" title=css>css">--i:3"></span>
                <span style="html" title=css>css">--i:4"></span>
                <span style="html" title=css>css">--i:5"></span>
                <span style="html" title=css>css">--i:6"></span>
                <span style="html" title=css>css">--i:7"></span>
                <span style="html" title=css>css">--i:8"></span>
            </div>
            <!-- 群山 -->
            <div class="mountain a"> </div>
            <div class="mountain b"> </div>
            <div class="mountain c"> </div>
            <div class="mountain d"> </div>
            <div class="mountain e"> </div>
        </div>
    </div>
    <script>
        let swch=document.getElementById('switch');
        swch.addEventListener('click',(e)=>{
            // swch.classList.toggle('switched');
            if(swch.classList.contains('switched')){
                swch.classList.remove('switched');
            } else{
                swch.classList.add('switched');
            }
        });
    </script>
</body>
</html>

html" title=css>css_62">html" title=css>css代码

html" title=css>css">:root {
    --background-color: #2c3e50;
    --border-color: #7591AD;
    --text-color: #34495e;
    --color1: #EC3E27;
    --color2: #fd79a8;
    --color3: #0984e3;
    --color4: #00b894;
    --color5: #fdcb6e;
    --color6: #e056fd;
    --color7: #F97F51;
    --color8: #BDC581;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html{
    font-size: 14px;
}
body{
    width: 100vw;
    height: 100vh;
    background-color: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family:  'Montserrat', sans-serif, Arial, 'Microsoft Yahei';
}
.channel{
    position: absolute;
    width: 80%;
    text-align: center;
    top: 10vh;
    left: 50%;
    transform: translateX(-50%);
    font-size: 5vmin;
    font-weight:bold ;
    color: #353535;
    z-index: 10000;
}
.container{
    width: 100vw;
    height: 100vh;
    /* background-color: #00b894; */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
/* **********************
*  速度切换开关
*  不用checkbox实现,我们用html" title=js>js控制样式来实现
*  ********************** */
#switch{
    position: relative;
    width: 60px;
    height: 30px;       
    border: 2px solid #333;     
    border-radius: 30px;          
    cursor: pointer;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
}

#switch::before,
#switch::after{
    position: absolute;
    line-height: 26px;
    text-transform: uppercase;
    font-weight: 800;
    padding: 0 20px;
    cursor: initial; 
    pointer-events: none;
}

#switch::before{
    content: 'slow';
    right: 90%;
    color: var(--color8);

}

#switch::after{
    content: 'fast';
    left: 90%;
    color: var(--color3);    
}
/* 默认情况 */
#switch #circle{
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border: 2px solid #333;
    border-radius: 50%;
    box-shadow: inset 4px -2px 0 0 var(--color8);
    transition: all .5s cubic-bezier(.74,1.28,.73,.99);
}
/* 点击选中的情况 */
#switch.switched #circle{
    left: calc(100% - 20px - 3px);
    box-shadow: inset 4px -2px 0 0 var(--color3);
}

/* **********************
*  这里是主画布外框
*  ********************** */
.main{
    position: relative;
    width: 400px;
    height: 300px;
    border: 2px solid #333;
    margin-top: 20px;
    overflow: hidden;
}

/* **********************
*  这里是太阳
*  ********************** */
.sun{
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #333;
    border-radius: 50%;
    left:270px;
    top: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: sun_rotate 10s linear infinite;
}
@keyframes sun_rotate{
    0%{
        transform: rotate(0deg);
    }
    100%{
        transform: rotate(360deg);
    }
}
.sun span{
    position: absolute;
    display: block;
    height: 2px;
    width: 16px;
    background-color: #333;
    transform: 
    rotate(calc(var(--i) * 45deg))
    translateX(-20px);
    box-shadow: 4px 4px 0 0 var(--color5);
    animation: sun_ray 1s linear infinite;
    animation-delay: calc(var(--i) * -0.5s);
}
@keyframes sun_ray{
    0%{
        transform:  rotate(calc(var(--i) * 45deg))
        translateX(-20px) scaleX(1);
    }
    50%{
        transform: rotate(calc(var(--i) * 45deg))
        translateX(-20px) scaleX(0.6);
    }
    100%{
        transform: rotate(calc(var(--i) * 45deg))
        translateX(-20px) scaleX(1);
    }
}

/* **********************
*  这里是群山
*  ********************** */
.mountain{
    position: absolute;
    border: 2px solid #333;
    transform: rotate(45deg);
}
.mountain.a{
    width: 14px;
    height: 14px;   
    left: 80px;
    bottom: 35px; 
}
.mountain.b{
    width: 18px;
    height: 18px;     
    left: 130px;
    bottom: 45px;    
}
.mountain.c{
    width: 20px;
    height: 20px;   
    left: 190px;
    bottom: 60px;      
}
.mountain.d{
    width: 2px;
    height: 2px; 
    left: 240px;
    bottom: 62px;      
    border-bottom: none;  
}
.mountain.e{
    width: 14px;
    height: 14px;     
    left: 285px;
    bottom: 41px;      
}
.mountain.a::after,
.mountain.b::after,
.mountain.c::after,
.mountain.d::after,
.mountain.e::after,
.mountain.a::before,
.mountain.b::before,
.mountain.c::before,
.mountain.d::before,
.mountain.e::before{
    position: absolute;
    content: '';
    background-color: #333;
}
.mountain.a::after,
.mountain.b::after,
.mountain.c::after,
.mountain.d::after,
.mountain.e::after{
    left: -2px;
    top: 100%;
    width: 2px;
}
.mountain.a::after{

    height: 70px;
}
.mountain.b::after{

    height: 50px;
}
.mountain.c::after{

    height: 70px;
}
.mountain.d::after{

    height: 14px;
}
.mountain.e::after{
    height: 18px;
}
.mountain.a::before,
.mountain.b::before,
.mountain.c::before,
.mountain.d::before,
.mountain.e::before{
    top: -2px;
    left: 100%;
    height: 2px;
}
.mountain.a::before{
    width: 14px;
    box-shadow: -5px -5px 0 0 var(--color4);
}
.mountain.b::before{
    width: 14px;
    box-shadow: -5px -5px 0 0 var(--color4);
}
.mountain.c::before{
    width: 36px;
    box-shadow: -14px -5px 0 0 var(--color4);
}
.mountain.d::before{
    width: 55px;
    box-shadow: 5px 5px 0 0 var(--color4);
}
.mountain.e::before{
    width: 70px;
    box-shadow: 5px 5px 0 0 var(--color4);
}

设计思路与今日份知识总结

设计思路

  • 1.先画一些小正方形
  • 2.before和after在正方形的垂直两边画延长线(可以先用和正方形不一样的颜色来区分,方便画线)
  • 3.调整小正方形到底部,然后进行一个rotate旋转就可以得到山了
  • 4.使用box-shadow给山加点绿植,就完成了,呵呵

知识总结

剩饭尔。无新知识!


http://www.niftyadmin.cn/n/1847110.html

相关文章

iOS:ComponentKit 使用总结

前言的前言 好。。开始做下ComponentKit使用总结。。源码没有看&#xff0c;只看了一些概念以及API。本篇文章主要总结下使用心得以及ComponentKit的理念。一切的分析都基于使用层面上的。。大神请打脸或略过~ 本文面向有一定开发经验的iOSer&#xff0c;以及喜欢折腾的iOSer..…

图论-连通图学习总结

一、有向图 有向图的问题就是直接Tarjan求强连通分量&#xff0c;然后搞就行。 二、无向图 1、割点和桥 无向图的割点和桥的求法和有向图的差不多&#xff0c;唯一多的限制就是不能从该点往他的父亲走&#xff0c;当然可能会有重边。但有统一的解决方法&#xff0c;那就是标记…

[JS-DOM BOM学习笔记]DOM重点核心(123总结)

DOM重点核心简单回顾前面的知识元素操作创建增删改查属性操作事件操作简单回顾前面的知识 文档对象模型(DOM)&#xff0c;是W3C组织推荐的处理可扩展标记语言(HTML或者XML)的标准编程接口。 W3C已经定义了一系列的DOM接口&#xff0c;通过这些DOM接口可以改变网页的内容&#…

Centos 用户组管理

#组帐号管理linux 组管理--------------------------------1&#xff0e;组的分类私用组&#xff1a;只能包含一个用户&#xff08;由创建用户的自动创建&#xff09;标准组&#xff1a;可以包含多个用户2&#xff0e;组的信息组名&#xff1a;组的标识符号GID&#xff1a;组的…

[JS-DOM BOM学习笔记]DOM事件高级导读

DOM事件高级导读目标汇总注册事件(绑定事件)传统注册方式方法监听注册方式addEventListener事件监听方式evenTarget.addEvenListener(type&#xff0c;listener&#xff0c;useCapture)样例代码删除事件(解绑事件)传统注册方式eventTarget.οnclicknull&#xff1b;方法监听注册…

基于Java+控制台+Mysql实现图书管理系统

基于Java控制台Mysql实现图书管理系统 一、系统介绍二、功能展示1.主页2.添加图书3.图书列表4.根据图书名称号查询图书信息5.根据编号删除图书信息6.根据编号编辑图书信息7.退出系统 三、数据库四、其它1.其他系统实现2.获取源码 一、系统介绍 使用控制台Mysql完成一个图书管理…

互联网协议(二)

互联网协议入门&#xff08;二&#xff09; 上一篇文章分析了互联网的总体构思&#xff0c;从下至上&#xff0c;每一层协议的设计思想。 这是从设计者的角度看问题&#xff0c;今天我想切换到用户的角度&#xff0c;看看用户是如何从上至下&#xff0c;与这些协议互动的。 互…

杭电2019多校第九场 HDU-6685 Rikka with Coin(思维+暴力)

链接&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid6685 题意&#xff1a;T组样例&#xff0c;每组样例会给出n个数&#xff0c;现在你有无穷多的10、20、50、100的硬币&#xff0c;问最少带多少硬币&#xff0c;可以这n个数都可以凑出来。如果不能输出-1。 思路&a…