Thêm code tuyết rơi cho trang web

Thêm code tuyết rơi cho trang web

Start Tiến IT đã đăng
Hiện có lượt xem và 0 bình luận
Chi tiết Liên quan Nhận xét Tác giả Hướng dẫn
  • Xem toàn trang
  • Bài viết này tôi sẽ hướng dẫn cho các bạn thêm code tuyết lên trang web của mình!

    HƯỚNG DẪN CÁCH LÀM:

    Để thêm tuyết rơi ta tìm thẻ <body> và thêm đoạn code sau dưới nó
    <style>
    #snowflakeContainer {
    position: absolute;
    left: 0px;
    top: 0px;
    }
    .snowflake {
    padding-left: 15px;
    font-family: Cambria, Georgia, serif;
    font-size: 14px;
    line-height: 24px;
    position: fixed;
    color: #FFFFFF;
    user-select: none;
    z-index: 1000;
    -moz-user-select: none;
    -ms-user-select: none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    }
    .snowflake:hover {
    cursor: default;
    }
    </style>
    <div id='snowflakeContainer'>
    <p class='snowflake'>*</p>
    </div>
    <script>// The star of every good animation
    var requestAnimationFrame = window.requestAnimationFrame ||
    window.mozRequestAnimationFrame ||
    window.webkitRequestAnimationFrame ||
    window.msRequestAnimationFrame;

    var transforms = [&quot;transform&quot;,
    &quot;msTransform&quot;,
    &quot;webkitTransform&quot;,
    &quot;mozTransform&quot;,
    &quot;oTransform&quot;];

    var transformProperty = getSupportedPropertyName(transforms);

    // Array to store our Snowflake objects
    var snowflakes = [];

    // Global variables to store our browser&#39;s window size
    var browserWidth;
    var browserHeight;

    // Specify the number of snowflakes you want visible
    var numberOfSnowflakes = 50;

    // Flag to reset the position of the snowflakes
    var resetPosition = false;

    //
    // It all starts here...
    //
    function setup() {
    window.addEventListener(&quot;DOMContentLoaded&quot;, generateSnowflakes, false);
    window.addEventListener(&quot;resize&quot;, setResetFlag, false);
    }
    setup();

    //
    // Vendor prefix management
    //
    function getSupportedPropertyName(properties) {
    for (var i = 0; i &lt; properties.length; i++) {
    if (typeof document.body.style[properties[i]] != &quot;undefined&quot;) {
    return properties[i];
    }
    }
    return null;
    }

    //
    // Constructor for our Snowflake object
    //
    function Snowflake(element, radius, speed, xPos, yPos) {

    // set initial snowflake properties
    this.element = element;
    this.radius = radius;
    this.speed = speed;
    this.xPos = xPos;
    this.yPos = yPos;

    // declare variables used for snowflake&#39;s motion
    this.counter = 0;
    this.sign = Math.random() &lt; 0.5 ? 1 : -1;

    // setting an initial opacity and size for our snowflake
    this.element.style.opacity = .1 + Math.random();
    this.element.style.fontSize = 12 + Math.random() * 50 + &quot;px&quot;;
    }

    //
    // The function responsible for actually moving our snowflake
    //
    Snowflake.prototype.update = function () {

    // using some trigonometry to determine our x and y position
    this.counter += this.speed / 5000;
    this.xPos += this.sign * this.speed * Math.cos(this.counter) / 40;
    this.yPos += Math.sin(this.counter) / 40 + this.speed / 30;

    // setting our snowflake&#39;s position
    setTranslate3DTransform(this.element, Math.round(this.xPos), Math.round(this.yPos));

    // if snowflake goes below the browser window, move it back to the top
    if (this.yPos &gt; browserHeight) {
    this.yPos = -50;
    }
    }

    //
    // A performant way to set your snowflake&#39;s position
    //
    function setTranslate3DTransform(element, xPosition, yPosition) {
    var val = &quot;translate3d(&quot; + xPosition + &quot;px, &quot; + yPosition + &quot;px&quot; + &quot;, 0)&quot;;
    element.style[transformProperty] = val;
    }

    //
    // The function responsible for creating the snowflake
    //
    function generateSnowflakes() {

    // get our snowflake element from the DOM and store it
    var originalSnowflake = document.querySelector(&quot;.snowflake&quot;);

    // access our snowflake element&#39;s parent container
    var snowflakeContainer = originalSnowflake.parentNode;

    // get our browser&#39;s size
    browserWidth = document.documentElement.clientWidth;
    browserHeight = document.documentElement.clientHeight;

    // create each individual snowflake
    for (var i = 0; i &lt; numberOfSnowflakes; i++) {

    // clone our original snowflake and add it to snowflakeContainer
    var snowflakeCopy = originalSnowflake.cloneNode(true);
    snowflakeContainer.appendChild(snowflakeCopy);

    // set our snowflake&#39;s initial position and related properties
    var initialXPos = getPosition(50, browserWidth);
    var initialYPos = getPosition(50, browserHeight);
    var speed = 5+Math.random()*40;
    var radius = 4+Math.random()*10;

    // create our Snowflake object
    var snowflakeObject = new Snowflake(snowflakeCopy,
    radius,
    speed,
    initialXPos,
    initialYPos);
    snowflakes.push(snowflakeObject);
    }

    // remove the original snowflake because we no longer need it visible
    snowflakeContainer.removeChild(originalSnowflake);

    // call the moveSnowflakes function every 30 milliseconds
    moveSnowflakes();
    }

    //
    // Responsible for moving each snowflake by calling its update function
    //
    function moveSnowflakes() {
    for (var i = 0; i &lt; snowflakes.length; i++) {
    var snowflake = snowflakes[i];
    snowflake.update();
    }

    // Reset the position of all the snowflakes to a new value
    if (resetPosition) {
    browserWidth = document.documentElement.clientWidth;
    browserHeight = document.documentElement.clientHeight;

    for (var i = 0; i &lt; snowflakes.length; i++) {
    var snowflake = snowflakes[i];

    snowflake.xPos = getPosition(50, browserWidth);
    snowflake.yPos = getPosition(50, browserHeight);
    }

    resetPosition = false;
    }

    requestAnimationFrame(moveSnowflakes);
    }

    //
    // This function returns a number between (maximum - offset) and (maximum + offset)
    //
    function getPosition(offset, size) {
    return Math.round(-1*offset + Math.random() * (size+2*offset));
    }

    //
    // Trigger a reset of all the snowflakes&#39; positions
    //
    function setResetFlag(e) {
    resetPosition = true;
    }</script>
    Vậy là xong rồi, thật đơn giản phải k nào? Nhớ thường xuyên vào blog để nhận thêm nhiều thủ thuật mới, hay nữa nhé!

    Mục Lục Nội Dung

      Minh Tiến IT

      Pass giải nén mặc định: truongblogger
      Chắc bạn cũng đã nhiều lần gặp những link của 123link dạng 123link.co tại những trang web chia sẻ nội dung số. Nhưng bạn không biết cách nào để truy cập vào đúng link gốc của nội dung mà mình muốn truy cập. Bài viết này sẽ giúp bạn làm điều đó.
      Đầu tiên bạn truy cập vào một link 123link. Khi bạn truy cập xong thì nội dung bạn thấy sẽ tựa như hình ở dưới.
      Trang 123link
      Trang 123link
      Đánh dấu check vào vô “I’m not a robot”. Sau đó sẽ có một bảng captcha hiện ra. Bạn trả lời theo câu hỏi của captcha rồi bấm Verify để xác nhận.
      I’m not a robot
      I’m not a robot
      Verify
      Verify
      Sau khi xác nhận captcha thành công thì bấm chọn nút “Click here to continue” để sang bước tiếp theo.
      Click here to continue
      Click here to continue
      Ở trang tiếp theo, bạn sẽ thấy một đồng hồ đếm ngược, thường thì nhiều nhất sẽ là 7 giây. Bạn đợi cho thời gian đếm ngược chạy hết.
      Bạn đợi cho thời gian đếm ngược chạy hết
      Bạn đợi cho thời gian đếm ngược chạy hết
      Khi thời gian đếm ngược chạy hết, bạn sẽ thấy nút Get Link hiện ra. Bạn bấm vào nút đó để truy cập đến đường link đã được rút gọn bởi 123link.
      Get Link
      Get Link
      Bạn cứ yên tâm là link từ 123link sẽ không có ẩn chứa những mối nguy hiểm như virus, các pop-up quảng cáo không lành mạnh và phiền toái khi bạn đang thao tác các bước để tới link đích.
      HIỆN CÓ 0 BÌNH LUẬN