111.【金橘社区1.0】(六)

简介: 111.【金橘社区1.0】

8. 特效烟花点击

<span class="js-cursor-container"></span>
<!-- 网页鼠标点击特效(爱心) -->
<script>
  ! function (e, t, a) {
  function r() {
    for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[
            e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x +
            "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e]
                    .scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
    requestAnimationFrame(r)
  }
  function n() {
  var t = "function" == typeof e.onclick && e.onclick;
  e.onclick = function (e) {
  t && t(), o(e)
}
}
  function o(e) {
  var a = t.createElement("div");
  a.className = "heart", s.push({
  el: a,
  x: e.clientX - 5,
  y: e.clientY - 5,
  scale: 1,
  alpha: 1,
  color: c()
}), t.body.appendChild(a)
}
  function i(e) {
  var a = t.createElement("style");
  a.type = "text/css";
  try {
  a.appendChild(t.createTextNode(e))
} catch (t) {
  a.styleSheet.cssText = e
}
  t.getElementsByTagName("head")[0].appendChild(a)
}
  function c() {
  return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math
  .random()) + ")"
}
  var s = [];
  e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e
  .mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
  setTimeout(e, 1e3 / 60)
}, i(
  ".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"
  ), n(), r()
}(window, document);
//-----------------------------
  (function fairyDustCursor() {
  var possibleColors = ["#D61C59", "#E7D84B", "#1B8798"]
  var width = window.innerWidth;
  var height = window.innerHeight;
  var cursor = { x: width / 2, y: width / 2 };
  var particles = [];
  function init() {
  bindEvents();
  loop();
}
  // Bind events that are needed
  function bindEvents() {
  document.addEventListener('mousemove', onMouseMove);
  window.addEventListener('resize', onWindowResize);
}
  function onWindowResize(e) {
  width = window.innerWidth;
  height = window.innerHeight;
}
  function onMouseMove(e) {
  cursor.x = e.clientX;
  cursor.y = e.clientY;
  addParticle(cursor.x, cursor.y, possibleColors[Math.floor(Math.random() * possibleColors.length)]);
}
  function addParticle(x, y, color) {
  var particle = new Particle();
  particle.init(x, y, color);
  particles.push(particle);
}
  function updateParticles() {
  // Updated
  for (var i = 0; i < particles.length; i++) {
  particles[i].update();
}
  // Remove dead particles
  for (var i = particles.length - 1; i >= 0; i--) {
  if (particles[i].lifeSpan < 0) {
  particles[i].die();
  particles.splice(i, 1);
}
}
}
  function loop() {
  requestAnimationFrame(loop);
  updateParticles();
}
  /**
   * Particles
   */
  function Particle() {
  this.character = "*";
  this.lifeSpan = 120; //ms
  this.initialStyles = {
  "position": "fixed",
  "display": "inline-block",
  "top": "0px",
  "left": "0px",
  "pointerEvents": "none",
  "touch-action": "none",
  "z-index": "10000000",
  "fontSize": "25px",
  "will-change": "transform"
};
  // Init, and set properties
  this.init = function (x, y, color) {
  this.velocity = {
  x: (Math.random() < 0.5 ? -1 : 1) * (Math.random() / 2),
  y: 1
};
  this.position = { x: x + 10, y: y + 10 };
  this.initialStyles.color = color;
  this.element = document.createElement('span');
  this.element.innerHTML = this.character;
  applyProperties(this.element, this.initialStyles);
  this.update();
  document.querySelector('.js-cursor-container').appendChild(this.element);
};
  this.update = function () {
  this.position.x += this.velocity.x;
  this.position.y += this.velocity.y;
  this.lifeSpan--;
  this.element.style.transform = "translate3d(" + this.position.x + "px," + this.position.y + "px, 0) scale(" + (this.lifeSpan / 120) + ")";
}
  this.die = function () {
  this.element.parentNode.removeChild(this.element);
}
}
  /**
   * Utils
   */
  // Applies css `properties` to an element.
  function applyProperties(target, properties) {
  for (var key in properties) {
  target.style[key] = properties[key];
}
}
  if (!('ontouchstart' in window || navigator.msMaxTouchPoints)) init();
})();
</script>

9. 前端引入 markdown编辑器 ---- 一定要和html处于同级目录下.

[Editor.md - 开源在线 Markdown 编辑器 (pandao.github.io)](https://pandao.github.io/editor.md/)

首先我们必须先要打开上面的网站: 然后点击安装下载: 就会跳转到一个Github项目中。安装一个压缩包

然后解压到我们的项目中:

<link rel="stylesheet" href="editor.md/css/editormd.min.css">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>
<!-- 正文:  -->
<div id="editor">
</div>
<script>
    var editor = editormd("editor", {
        // 这里的尺寸必须在这里设置,设置样式会被 editormd 自动覆盖
        width: "100%",
        // 设置高度
        height: "500px",
        // 编辑器中初始内容
        markdown: "# 在这里写下一篇博客",
        // 指定插件路径
        path: "editor.md/lib/"
    });
</script>

10. 百度搜索框

<!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">
  <title>Serach</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    .top-search {
      width: 680px;
      height: 45px;
      margin: 30px auto;
    }
    .search-box {
      display: flex;
      position: relative;
    }
    .search-left {
      width: 545px;
      height: 45px;
      border: 2px solid rgb(196, 199, 206);
      border-top-left-radius: 10px;
      border-bottom-left-radius: 10px;
      outline-color: rgb(78, 110, 242);
    }
    .icon-xiangji {
      position: absolute;
      right: 150px;
      top: 12px;
      font-size: 24px;
      color: rgb(196, 199, 206);
    }
    .search-right {
      color: #fff;
      font-size: 18px;
      width: 110px;
      height: 49px;
      border: 0px;
      border-top-right-radius: 10px;
      border-bottom-right-radius: 10px;
      background-color: rgb(78, 110, 242);
    }
            #su:hover{
            background: #14dc99;
        }
  </style>
</head>
<body>
<form action="mainMenu.html">
<div class="top-img"></div>
<div class="top-search">
  <div class="search-box">
      <input type="text" name="search" class="search-left">
      <span class="iconfont icon-xiangji"></span>
      <input class="search-right" type="subbmit" name="btn" id="su" value='发表文章'>
  </div>
</div>
</form>
</body>
</html>

11. 二维码弹窗!!!

<!DOCTYPE html>
<html>
<head>
  <title>test1</title>
  <meta charset="UTF-8">
  <%--注意引用和地址--%>
  <script src="static/Jquery/jquery-3.6.1.js"></script>
  <script src="static/layui/layui.js" charset="utf-8"></script>
  <script src="https://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
  <link rel="stylesheet" href="static/layui/css/layui.css"  media="all">
</head>
<body>
<div align="center">
  <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" onclick="skipHandle()">预览</button>
</div>
<div id="code" style="display: none;">
  <div id="qrcode" style="margin-left: 75px;margin-top: 20px">
   <h1 style="color: #e8136f">你好</h1>
  </div>
</div>
<script>
  layui.use(['layer'], function () {
    var layer = layui.layer
  });
  // 设置要生成二维码的链接
  new QRCode(document.getElementById("qrcode"), {
    text: "https://img-home.csdnimg.cn/images/20230407093553.jpg", //设置二维码内容
    canvas: "table", //设置渲染方式
    width: 250,
    height: 250
  });
  //预览等弹出框
  function skipHandle() {
    layer.open({
      type: 1,
      title: "bug_producter的博客",//标题
      area: ['400px', '400px'],
      content: $('#code').html(),
    });
  }
</script>
</body>
</html>


12. 文本框不能为空格的属性,一个属性就可以

οnkeyup="this.value=this.value.replace(/\s+/g,'')"


相关文章
|
前端开发 JavaScript
111.【金橘社区1.0】(二)
111.【金橘社区1.0】
53 0
|
前端开发
111.【金橘社区1.0】(五)
111.【金橘社区1.0】
75 0
|
5月前
|
Linux 开发者
Linux底层驱动社区饮水机系统详解
在Linux驱动开发中,入门时通常会关注驱动程序的三大核心步骤:入口函数、出口函数和声明许可证。这些步骤构成了驱动程序的基本结构,是驱动与内核交互的基础。下面是对这三个步骤的简要说明:
|
前端开发 JavaScript Java
111.【金橘社区1.0】(一)
111.【金橘社区1.0】
118 0
111.【金橘社区1.0】(一)
|
SQL JavaScript 前端开发
111.【金橘社区1.0】(四)
111.【金橘社区1.0】
51 0
|
前端开发
111.【金橘社区1.0】(三)
111.【金橘社区1.0】
48 0
|
开发者
我和社区的2022
简述我和社区一路走来的点点滴滴
我和社区的2022
|
数据安全/隐私保护 Docker 容器
JetLinks 社区版安装
JetLinks 社区版安装
562 0
|
Cloud Native 数据可视化 关系型数据库
训练营 | 如何成为一名开源社区贡献者?
「云原生应用插件扩展训练营」由阿里云云原生团队围绕 KubeVela、OpenYurt、Koordinator、OpenKruise、Fluid 等云原生开源项目打造,为了帮助更多开发者感受开源社区的魅力,了解如何更快地参与社区贡献。
训练营 | 如何成为一名开源社区贡献者?
|
云计算 开发者
阿里云社区
学习阿里云