鱼C论坛

 找回密码
 立即注册
楼主: 不二如是

[庖丁解牛] 0 0 1 6 - 分组分段元素

[复制链接]
发表于 2021-10-25 10:30:10 | 显示全部楼层
I love fishc
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-1-21 21:44:39 | 显示全部楼层
告诉我tellme
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-5-8 08:51:23 | 显示全部楼层
学习
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-5-23 23:32:10 From FishC Mobile | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-5-24 14:04:00 | 显示全部楼层
!!!
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2023-7-24 21:37:33 | 显示全部楼层
打卡
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2023-9-22 22:56:58 | 显示全部楼层
怪,这个帖子隐藏了什么呢?
不如放点课上写的网站好了
index.html
  1. <!doctype html>
  2. <html lang="zh-CN">
  3.         <head>
  4.                         <meta charset = "utf-8">
  5.                         <title>Welcome to the my blog!</title>
  6.                         <link href="study.css" rel="stylesheet">
  7.         </head>
  8.         <body>
  9.                 <div id = "introduction">
  10.                         <p id = "me">白月松江,晚霞秋霜,小生易改乌江水</p>
  11.                         <div class = "a_element" id = "ball_caller">
  12.                                 <a>main_page</a>
  13.                         </div>
  14.                 </div>
  15.                 <div id = "main_page">

  16.                 </div>
  17.                 <script src="study.js"></script>
  18.         </body>
  19. </html>
复制代码

study.js
  1. var call = document.getElementById("ball_caller");
  2. var click_a = true
  3. call.onclick = function my(){
  4.                 if (click_a){
  5.                 //获取浏览器窗口宽高
  6.         var W,H;
  7.         W = document.documentElement.clientWidth;
  8.         H = document.documentElement.clientHeight;

  9.         var mdAttr = document.createDocumentFragment();
  10.         var OBall = [];//小球对象数组
  11.             OBall[0] = document.createElement("div");
  12.             OBall[0].setAttribute("class", "ball");
  13.             var cirR = 30 * random(0) + 10;
  14.             OBall[0].style.width = cirR * 2 + "px";
  15.             OBall[0].style.height = cirR * 2 + "px";
  16.             OBall[0].style.background = "radial-gradient(circle," + "rgba(255,222,0,0.6)" + "," + "rgba(255,222,0,0)" + ")";
  17.             mdAttr.appendChild(OBall[0]);
  18.             OBall[0].onclick = function () {
  19.                 if (cirR > 20) {
  20.                     // click_a = true;
  21.                     top.location.href = "/yellowpage";
  22.                     document.removeChild(OBall[0]);
  23.                 }
  24.                 if (cirR < 20) {
  25.                     // click_a = true;
  26.                     top.location.href = "/yellowpage";
  27.                     document.removeChild(OBall[0]);
  28.                 }
  29.             }
  30.             OBall[0].startX = W * (random(0) - 0.5) * 0.4 + 0.5 * W;
  31.             OBall[0].startY = H * (random(0) - 0.5) * 0.4 + 0.5 * H;
  32.             OBall[0].Vx = 2 * random(0);
  33.             OBall[0].Vy = 2 * random(0);
  34.         document.body.appendChild(mdAttr);
  35.                 click_a = false;

  36.         //运动
  37.         ~function fn() {
  38.             window.onresize = function () {
  39.                 W = document.documentElement.clientWidth;
  40.                 H = document.documentElement.clientHeight;
  41.             };
  42.             OBall.forEach(function (ball) {
  43.                 var MaxH = H - ball.offsetHeight,
  44.                     MaxW = W - ball.offsetWidth;
  45.                 ball.startX += ball.Vx;
  46.                 ball.startY += ball.Vy;
  47.                 if(ball.startX+ball.Vx >= MaxW || ball.startX+ball.Vx <=0){
  48.                     ball.Vx *= -1.25*(0.8*random(0)+0.4);
  49.                     if(Math.abs(ball.Vx)>0.3*MaxW)
  50.                     {
  51.                         ball.Vx = Math.sign(ball.Vx)*0.3*MaxW;
  52.                     }
  53.                     ball.startX = Math.max(ball.Vx,ball.startX+ball.Vx);
  54.                     ball.startX = Math.min(ball.startX+ball.Vx,MaxW+ball.Vx);
  55.                 }
  56.                 if(ball.startY+ball.Vy >= MaxH || ball.startY+ball.Vy <=0){
  57.                     ball.Vy *= -1.25*(0.8*random(0)+0.4);
  58.                     if(Math.abs(ball.Vy)>0.3*MaxH)
  59.                     {
  60.                         ball.Vy = Math.sign(ball.Vy)*0.3*MaxH;
  61.                     }
  62.                     ball.startY = Math.max(ball.Vy,ball.startY+ball.Vy);
  63.                     ball.startY = Math.min(ball.startY+ball.Vy,MaxW+ball.Vy);
  64.                 }
  65.                 ball.style.left = ball.startX + "px";
  66.                 ball.style.top = ball.startY + "px";


  67.             });
  68.             requestAnimationFrame(fn);//循环
  69.         }();
  70. }

  71.         function random(min,max){
  72.             return Math.random()+min;
  73.         }
  74.                 }
复制代码

study.css
  1. @charset "utf-8";
  2.                                 html,body{
  3.                                         height : 100%;
  4.                                         font-family: sans-serif;
  5.                                 }
  6.                                 body{
  7.                                         background:url(background.png) center 4vw;
  8.                                         background-size:cover;
  9.                                         margin: 0;
  10.                                         padding:0;
  11.                                         position: relative;
  12.                                         font-family: Tahoma, sans-serif;
  13.                                 }
  14.                                 #introduction{
  15.                                         position: absolute;
  16.                                         top:15%;
  17.                                         left: 50%;
  18.                                         width:80%;
  19.                                         text-align:center;
  20.                                         transform: translate3d(-50%,-50%,0);
  21.                                         color:#000000;
  22.                                         background:rgba(192,172,98, 0.7);/*#39C5BB;*/
  23.                                         /*background-color: #c0ac62;*/
  24.                                         border:1px solid #9d8d51;
  25.                                         border-radius: 40px;
  26.                                         text-decoration: none;
  27.                                 }
  28.                                 #me{
  29.                                         font-family: KaiTi, sans-serif;
  30.                                         font-size:42px;
  31.                                         margin-bottom:22px;
  32.                                 }
  33.                                 .a_element{
  34.                                         position:relative;
  35.                                         font-size: 23px;
  36.                                         height: auto;
  37.                                         width: 30vw;
  38.                                         left: 50%;
  39.                                         transform: translate3d(-50%,0,0);
  40.                                         background: rgba(51,150,150,0.9);
  41.                                         color:#FFF;
  42.                                         border:1px solid rgb(51,136,136);
  43.                                         border-radius: 20px;
  44.                                         padding:10px 5px;
  45.                                         text-align: center;
  46.                                 }
  47.                                 .ball {
  48.                                         position: absolute;
  49.                                         top: 0;
  50.                                         left: 0;
  51.                                         width: 100px;
  52.                                         height: 100px;
  53.                                         background: radial-gradient(circle, #fff, #fff600);
  54.                                         border-radius: 50%;
  55.                                 }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-10-9 16:33:08 | 显示全部楼层
1

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-5 14:23

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表