首页 > 其他分享 >【HTML页面】 每周更新的HTML好玩样式和页面

【HTML页面】 每周更新的HTML好玩样式和页面

时间:2024-09-07 20:20:55浏览次数:13  
标签:em 100% nth HTML background child div 好玩 页面

本周有些迟到 下面直接看页面吧

星空个人介绍页

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

*{ box-sizing: border-box; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; scroll-behavior: smooth;}
html, body { height: 100%; }

html::-webkit-scrollbar { display: none; }
html { -ms-overflow-style: none; scrollbar-width: none; }

body {
    margin: 0;
    font-family: Untitled Sans, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, sans-serif;
    background: #05060f linear-gradient(0deg,rgba(216,236,248,.06),rgba(152,192,239,.06));

    font-size: max(calc(var(--_size) * 0.03), 10px);
    --_factor: min(600px, 80vh);
    --_size: min(var(--_factor), 80vw);
}

body.gold .header h2 ,
body.gold p,
body.gold > * > * :not(.contact-btn) {
    filter: invert(1) brightness(4.7);
}
body.gold .header h2 a{
    filter: hue-rotate(0deg);
}
body.gold canvas {
    filter: drop-shadow(2em 4em 0px #d8bd10) drop-shadow(-8em -14em 0px #d8bd10);
}
body.gold .header .spotlight {
    filter: invert(1) brightness(4.7) opacity(0.5);
}
body.gold .mountains > div {
    box-shadow: 
    -1em -0.2em 0.4em -1.1em #c2ccff,
    inset 0em 0em 0em 2px #d8a910,
    inset 0.2em 0.3em 0.2em -0.2em #c2ccff,
    inset 10.2em 10.3em 2em -10em #d4e6ff2f;
}

body.gold .content-section,
body.gold .content-section ::before,
body.gold .content-section ::after{
    filter: invert(1) brightness(4.4) opacity(1);
}

h2 {
    font-family: 'Hubot-Sans', sans-serif;
}
h2, p {
    margin: 0; padding: 0;
}
h2 a {
    text-decoration: none;
    color: unset;
}

.header {
    display: flex; width: 100%;
    justify-content: center;
    color: #bad6f7;
    padding: 2em;
    position: absolute;
    top: 0; left: 0; right: 0; margin: 0 auto;

    opacity: 0;
    translate: 0 -1em;
    animation: load 2s ease-in 2s forwards, up 1.4s ease-out 2s forwards;
}
.header > :nth-child(1) {
    font-size: 1em;
    position: absolute; left: 0; right: 29em; margin: 0.2em auto;
    width: fit-content;
}
.header > :nth-child(2) {
    position: absolute; left: 0; right: 0; margin: 0 auto;
    width: fit-content;
}
.header > h2{
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.04s ease-in-out;
}
.header > h2:hover {
    opacity: 1;
    text-shadow: 0 2px 16px rgba(174,207,242, 0.6);
    width: fit-content;
}

.header > div.mid-spot {
    width: 1.8em; height: 1.8em;
    border-radius: 50%;
    background: black;
    box-shadow: 0 0 1em 0 #98c0ef;
    cursor: pointer;
    transition: box-shadow 1s ease-in-out;
}
.header > div.mid-spot:hover {
    box-shadow: -0.3em 0.1em 0.2em 0 #d8bd10;
}
body.gold .header > div.mid-spot:hover {
    box-shadow: -0.3em 0.1em 0.2em 0 #98c0ef;
}

body.gold .header > div.mid-spot {
    box-shadow: 0 0 1em 0 #d8bd10;
}

.header > :nth-child(2):hover ~ .spotlight {
    animation: colorize 10s linear infinite;
}
@keyframes colorize {
    0%{filter: hue-rotate(0deg); }
    100% {filter: hue-rotate(-380deg);}
}

button.contact-btn {
    position: absolute; left: min(46em, 60vw); right: 0; margin: 0 auto;
    width: 8em; height: 2.4em;
    cursor: pointer;
    border-radius: 20em;
    border: none;
    transition: all 0.5s, transform 0.5s;
    
    border: 1px solid #c2ccff33;
    opacity: 1;
    padding-top: 0.3em;

    background: #121521;
    color: #9dc3f7;
    white-space:nowrap;
}
button.contact-btn::before {
    content: ''; display: block; position:absolute; left: 0; top:0; border-radius: 20em;
    width: 100%; height: 100%;
    background: #c2ccff91 radial-gradient(farthest-side at 50% 100%, #c2ccff, transparent);
    opacity: 0.1;
    transition: all 0.4s ease-in-out;
}
button.contact-btn:hover::before {
    background: #c2ccff1e radial-gradient(farthest-side at 50% 100%, #c2ccff, transparent);
    opacity: 0.3;
}
.contact-btn .glow {
    --border-width: 1px;
    --loop-cycle: 24s;
    position: absolute;
    inset: calc(var(--border-width)* -1);
    border-radius: 50px;
    border: var(--border-width) solid transparent;
    -webkit-mask: linear-gradient(transparent, transparent), linear-gradient(white, white);
    mask: linear-gradient(transparent, transparent), linear-gradient(white, white);
    -webkit-mask-clip: padding-box, border-box;
    mask-clip: padding-box, border-box;
    -webkit-mask-composite: source-in, xor;
    mask-composite: intersect;
    pointer-events: none;
}
button.contact-btn:hover .glow {
    --loop-cycle: 2s;
}
.contact-btn .glow::after, .contact-btn .glow::before {
    content: "";
    height: 100%;
    offset-anchor: 100% 50%;
    background: radial-gradient(circle at 50% 50%, hsla(0, 0%, 100%, 0.75), transparent 50%), radial-gradient(circle at 50% 50%, #c2ccff 50%, transparent);
    opacity: 0.4;
    offset-path: rect(0 100% 100% 0 round 33px);
    position: absolute;
    display: inline-block;
    -webkit-animation: loop 4s linear infinite;
    animation: loop var(--loop-cycle) linear infinite;
    aspect-ratio: 1 / 1;
    transition: opacity 1s ease-in-out;
}
.contact-btn .glow::before {
    animation-delay: calc( var(--loop-cycle) / -2 );
}
@keyframes loop {
    100% {
        offset-distance: 100%;
    }    
}
.contact-btn-content {
    background: linear-gradient(0deg, #d8ecf8, #98c0ef);
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.2em;
    line-height: 142%;
}
button.contact-btn:hover .glow::after, button.contact-btn:hover .glow::before {
    opacity: 0.6;
}
@keyframes btn-rot {
    0% { rotate: 0deg; }
    100% { rotate: 360deg; } 
}

.header .spotlight {
    pointer-events: none;
    position: absolute; left: 0; right: 0; top:0; margin: 0 auto;
    transition: filter 1s ease-in-out;

    height: 42em; width: 100%;
    overflow: hidden;
}
.header .spotlight > div {
    border-radius: 0 0 50% 50%;
    position: absolute; left: 0; right: 0; margin: 0 auto; 
    top: 3em;
    width: 30em; height: max(42em, 86vh);
    background-image: conic-gradient(from 0deg at 50% -5%, transparent 45%, rgba(124, 145, 182, .3) 49%, rgba(124, 145, 182, .5) 50%, rgba(124, 145, 182, .3) 51%, transparent 55%);
    transform-origin: 50% 0;
    filter: blur(15px) opacity(0.5);
    z-index: -1;
    animation: load 2s ease-in-out forwards, loadrot 2s ease-in-out forwards, spotlight 21s ease-in-out infinite reverse;
}
.header .spotlight > div:nth-child(1){ 
    rotate: 20deg;
    animation: load 2s ease-in-out forwards, loadrot 2s ease-in-out forwards, spotlight 17s ease-in-out infinite;
}
.header .spotlight > div:nth-child(2){ 
    rotate: -20deg;
    animation: load 2s ease-in-out forwards, loadrot 2s ease-in-out forwards, spotlight 14s ease-in-out infinite;
}
@keyframes loadrot {
    0% { rotate: 0deg; scale: 0;}
    100% { scale: 1;}
}
@keyframes spotlight {
    0% {
        transform: rotateZ(0deg) scale(1);
        filter: blur(15px) opacity(0.5);
    }
    20% {
        transform: rotateZ(-1deg) scale(1.2);
        filter: blur(16px) opacity(0.6);
    }    
    40% {
        transform: rotateZ(2deg) scale(1.3);
        filter: blur(14px) opacity(0.4);
    }    
    60% {
        transform: rotateZ(-2deg) scale(1.2);
        filter: blur(15px) opacity(0.6);
    }    
    80% {
        transform: rotateZ(1deg) scale(1.1);
        filter: blur(13px) opacity(0.4);
    }    
    100% {
        transform: rotateZ(0deg) scale(1);
        filter: blur(15px) opacity(0.5);
    }    
}

canvas#particleCanvas {
    position: absolute; pointer-events: none;
    animation: load 0.4s ease-in-out forwards;
    z-index: 1;
    width: 100%;
}

p {
    font-size: 1.5em;
}

.hero {
    width: 100%;
    height: 100%;
    max-height: 140px;
    position: absolute; top: 16em;
}

.heroT {
    position: absolute; left: 0; right: 0; margin: auto;
    height: 20em;
    padding-top: 2em;
    translate: 0 -1.6em;
    opacity: 0;
    animation: load 2s ease-in-out 0.6s forwards;
}
@keyframes load {  
    0% { opacity: 0;}    
    100% { opacity: 1;}    
}
.heroT > h2 {
    position: absolute;left: 0; right: 0; margin: auto;
    width: fit-content;
    
    font-size: 7em;
    font-weight: 600;
    color: #9dc3f7;
    background:
    radial-gradient( 2em 2em at 50% 50%,
        transparent calc(var(--p) - 2em),
        #fff calc(var(--p) - 1em), 
        #fff calc(var(--p) - 0.4em), 
        transparent var(--p) 
    ),
    linear-gradient(0deg, #bad1f1 30%, #9dc3f7 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 16px rgba(174,207,242,.24);

    --p:0%;
    transition:--p 3s linear;
    
    animation: pulse 10s linear 1.2s infinite;
}

.heroT h2:nth-child(2) {
    background:
    radial-gradient( 2em 2em at 50% 50%,
        transparent calc(var(--p) - 2em),
        transparent calc(var(--p) - 1em),
        #fff calc(var(--p) - 1em), 
        #fff calc(var(--p) - 0.4em), 
        transparent calc(var(--p) - 0.4em), 
        transparent var(--p) 
    );
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: blur(16px) opacity(0.4);
}
@keyframes pulse { 
    0% { --p:0%; }
    50% { --p:300%;}
    100% { --p:300%;}
}
@property --p {
    syntax: '<percentage>';
    inherits: false;
    initial-value: 0%;
}

.heroP {
    font-size: 1.2em;
    position: absolute; left: 0; right: 0; top: 20.6em; margin: auto;
    height: fit-content; width: fit-content; text-align: center;
    opacity: 0;
    translate: 0 1em;
    animation: load 2s ease-out 2s forwards, up 1.4s ease-out 2s forwards;
    color: #d8ecf8;
    text-shadow: 0 2px 16px rgba(174,207,242,.24);
    background: linear-gradient(0deg, #d8ecf8 0, #98c0ef 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
@keyframes up {      
    100% { translate: 0; }    
}

.heroSubP {
    position: absolute; left: 0; right: 0; top: 13em; margin: auto;
    height: fit-content;
    opacity: 0;
    translate: 0 -1em;
    animation: load3 2s ease-in 0s forwards, up 1.4s ease-out 0s forwards;
}
@keyframes load3 {  
    0% { opacity: 0;}    
    100% { opacity: 0.7;}    
}
.heroSubP p {
    font-size: 1em;
    position: relative; width: fit-content; margin: auto;
    color: #d8ecf8;
    text-shadow: 0 2px 16px rgba(174,207,242,.24);
    background: linear-gradient(0deg, #d8ecf8 0, #98c0ef 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.heroSubP p::before,
.heroSubP p::after {
    position: absolute; top: 60%; 
    display: block; content: '';
    width: 5em; height: 1px;
    opacity: 0;
    animation: load2 1.4s ease-in-out 0s forwards, up 1.4s ease-out 0s forwards;
}
@keyframes load2 {  
    0% { opacity: 0;}    
    100% { opacity: 0.3;}    
}
.heroSubP p::before{
    background: linear-gradient( -90deg, #9dc3f7 0%, transparent 100%);
    right: 120%;
    translate: -5em 0;
}
.heroSubP p::after {
    background: linear-gradient( 90deg, #9dc3f7 0%, transparent 100%);
    left: 120%;
    translate: 5em 0;
}

.accent-lines {
    pointer-events: none;
    position: absolute; top: 0; left: 0; right: 0;
    width: 100%; height: 42em;
    z-index: -2;
    --accent-lines-clr: rgba(186, 215, 247, .18);
}
.accent-lines > div {
    position: absolute; top: 0; right: 0; left: 0; margin: auto;
    height: 100%; width: 100%;
}
.accent-lines > div:nth-child(1) > div{
    position: absolute; top: 0; right: 0; left: 0; margin: auto;
    width: 100%; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-lines-clr), transparent);
    opacity: 0; scale: 0;
    animation: accentload 2s ease-out 2.4s forwards;
}
.accent-lines > div:nth-child(1) > div:nth-child(1){ top: 6em; }
.accent-lines > div:nth-child(1) > div:nth-child(2){ top: 11em; }
.accent-lines > div:nth-child(1) > div:nth-child(3){ top: 16em; }
.accent-lines > div:nth-child(1) > div:nth-child(4){ top: 24em; }
.accent-lines > div:nth-child(1) > div:nth-child(5){ top: 29em; }
.accent-lines > div:nth-child(2) > div{
    position: absolute; top: 0; right: 0; left: 0; margin: auto;
    width: 1px; height: 100%;
    background: var(--accent-lines-clr);
}
@keyframes accentload {
    0% {
        opacity: 0; scale: 0;
    }
    100% {
        opacity: 1; scale: 1;
    }
}

.accent-lines > div:nth-child(2) > div {
    opacity: 0; scale: 0;
    animation: accentload 2s ease-out 2s forwards;
}
.accent-lines > div:nth-child(2) > div:nth-child(1){ left: 24em; }
.accent-lines > div:nth-child(2) > div:nth-child(2){ left: 34em; }
.accent-lines > div:nth-child(2) > div:nth-child(3){ right: 24em; }
.accent-lines > div:nth-child(2) > div:nth-child(4){ right: 34em; }

.accent-lines > div:nth-child(1) > div::before, 
.accent-lines > div:nth-child(1) > div::after { 
    content: ''; display: none; position: absolute;
    width: 0.2em; height: 0.2em; border-radius: 1em;
    background: #9dc3f7;
    left: 0; right: 0; margin: auto;
    translate: 0 -1px;

    opacity: 0; scale: 0;
    animation: accentload 2s ease-out 4.4s forwards;
}

.accent-lines > div:nth-child(1) > div:nth-child(3)::before{ display: block; left: 24em; }
.accent-lines > div:nth-child(1) > div:nth-child(3)::after{ display: block; right: 24em; }
.accent-lines > div:nth-child(1) > div:nth-child(4)::before{ display: block; left: 24em; }
.accent-lines > div:nth-child(1) > div:nth-child(4)::after{ display: block; right: 24em; }
.accent-lines > div:nth-child(1) > div:nth-child(5)::before{ display: block; left: 24em; }
.accent-lines > div:nth-child(1) > div:nth-child(5)::after{ display: block; right: 24em; }

.accent-lines > div:nth-child(1) > div:nth-child(2)::before,
.accent-lines > div:nth-child(1) > div:nth-child(2)::after{ 
    display: block; width: 5em; height: 1px; border-radius: 0; opacity: 0.12;
}
.accent-lines > div:nth-child(1) > div:nth-child(2)::before{
    right: 24em; rotate: 45deg; translate: -2.5em 2.5em;
}
.accent-lines > div:nth-child(1) > div:nth-child(2)::after{
    right: 24em; rotate: -45deg; translate: -2.5em 2.5em;
}
.accent-lines > div:nth-child(1) > div:nth-child(1)::before,
.accent-lines > div:nth-child(1) > div:nth-child(1)::after{ 
    display: block; width: 5em; height: 1px; border-radius: 0; opacity: 0.12;
}
.accent-lines > div:nth-child(1) > div:nth-child(1)::before{
    left: 24em; rotate: 45deg; translate: 2.5em 7.5em;
}
.accent-lines > div:nth-child(1) > div:nth-child(1)::after{
    left: 24em; rotate: -45deg; translate: 2.5em 7.5em;
}

.accent-lines > div:nth-child(1) > div:nth-child(2)::before,
.accent-lines > div:nth-child(1) > div:nth-child(2)::after {
    opacity: 0; scale: 0;
    animation: accentload2 2s ease-out 2.4s forwards;
}
.accent-lines > div:nth-child(1) > div:nth-child(1)::before,
.accent-lines > div:nth-child(1) > div:nth-child(1)::after {
    opacity: 0; scale: 0;
    animation: accentload3 2s ease-out 2.4s forwards;
} 
@keyframes accentload2 {
    0% {
        opacity: 0; scale: 0; transform: rotate(360deg);
    }
    50% { scale: 0; }
    100% {
        opacity: 0.12; scale: 1; transform: rotate(0deg);
    }
}
@keyframes accentload3 {
    0% {
        opacity: 0; scale: 0; transform: rotate(-360deg);
    }
    50% { scale: 0; }
    100% {
        opacity: 0.12; scale: 1; transform: rotate(0deg);
    }
}

.mountains {
    position: absolute; left: 0; right: 0; top: 31em; margin: auto;
    width: 100%; height: 10em;
    pointer-events: none;
}
.mountains::before {
    content: ''; display: block;
    width: 100%; height: 500%;
    position: absolute; top: 0%;
    background: linear-gradient(90deg, #121521 0%, transparent 50%);
    background: linear-gradient(0deg, #121521 80%, transparent 90%);
    z-index: 2;
}
.mountains > div {
    box-shadow: 
    -1em -0.2em 0.4em -1.1em #c2ccff,
    inset 0em 0em 0em 2px #c2ccff,
    inset 0.2em 0.3em 0.2em -0.2em #c2ccff,
    inset 10.2em 10.3em 2em -10em #d4e6ff2f;
    background: #121521;
    z-index: 1;
    filter: brightness(0.8);
    position: absolute; left: 0; right: 0; margin: auto;
    width: 20em; height: 20em;
    rotate: 45deg;
}
.mountains > div:nth-child(1) {
    bottom: -240%; 
    translate: -6em 2em;
    animation: mountainload1 2s ease-out 2.4s forwards;
}
.mountains > div:nth-child(2) {
    bottom: -240%;
    translate: -2em 0em;
    width: 14em; height: 20em;
    animation: mountainload2 2s ease-out 2.2s forwards;
}
.mountains > div:nth-child(3) {
    bottom: -240%; 
    translate: 6em 3em;
    animation: mountainload1 2s ease-out 2s forwards;
}
@keyframes mountainload1 {
    0% { bottom: -240%; }
    100% { bottom: -140%; }
}
@keyframes mountainload2 {
    0% { bottom: -240%; }
    100% { bottom: -108%; }
}
.mountains > div::before {
    content: ''; display: block;
    background: repeating-radial-gradient( at 100% 100%, transparent 0%, #c2ccff22 2px, transparent 4px);
    width: 12em; height: 12em;
    position: absolute;
    left: 0; top: 0;
    border-bottom-right-radius: 100%;
}

.hero-spacer {
    height: 40em;
    pointer-events: none;
}

.content-section {
    position: relative;
    z-index: 1112;
    color: #fff;
    width: 100%;
    text-align: center;
    padding: 16em 0 12em 0;
    overflow: hidden;
}

.content-section p.subt {
    color: #d8ecf8be;
    font-size: 0.8em;
    font-weight: 200;
    position: relative;
    width: fit-content;
    margin: auto;
}
.content-section h3 {
    margin: 0.4em 0 0.6em 0;
    font-size: 2.3em;
    font-weight: 600;
    color: #d8ecf8;
    text-shadow: 0 2px 16px rgba(174,207,242,.24);
    background: linear-gradient(0deg, #d8ecf8 0, #98c0ef 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.content-section p.subp {
    color: #d8ecf8be;
    font-size: 1em;
    font-weight: 400;
    max-width: 26em;
    margin: auto;
}

.content-section p.subt::before,
.content-section p.subt::after {
    position: absolute; top: 60%; 
    display: block; content: '';
    width: 5em; height: 1px;
    opacity: 0.5;
}
.content-section p.subt::before{
    background: linear-gradient( -90deg, #9dc3f7 0%, transparent 100%);
    right: 120%;
    top: 50%;
}
.content-section p.subt::after {
    background: linear-gradient( 90deg, #9dc3f7 0%, transparent 100%);
    left: 120%;
    top: 50%;
}

.content-section .content-acc {
    position: absolute;
    left: 0; right: 0; top: 25%; margin: auto;
    display: flex; justify-content: center;
}
.content-section .content-acc div{
    width: 10em; height: 10em;
    border-radius: 50%;
    box-shadow: 
    -1em -0.2em 0.4em -1.1em #c2ccff,
    inset 0em 0em 0em 2px #c2ccff,
    inset 0.2em 0.3em 0.2em -0.2em #c2ccff,
    inset -1.2em 2.3em 2em -0.5em #d4e6ff2f;
    background: #121521;
    z-index: 1;
    filter: brightness(0.8);
    background: repeating-radial-gradient( at 50% 50%, transparent 0%, #c2ccff22 2px, transparent 4px);
    translate: -18em;
}
.content-section .content-acc div:nth-child(2){
    translate: 18em 12em;
    border-radius: 2em;
    box-shadow: 
    -1em -0.2em 0.4em -1.1em #c2ccff,
    inset 0em 0em 0em 2px #c2ccff,
    inset 0.2em 0.3em 0.2em -0.2em #c2ccff,
    inset 10.8em 11.3em 2em -10.5em #d4e6ff2f;
    background-color: inherit;
}

    </style>
</head>

<body>

<div class="header">
    <div class="mid-spot" onclick="document.body.classList.toggle('gold');"></div>
    <button class="contact-btn">
      <span class="glow"></span>
    </button>
  
    <div class="spotlight">
      <div></div>
      <div></div>
      <div></div>
    </div>
  </div>
  
  <canvas id="particleCanvas"></canvas>
  
  <div class="accent-lines">
    <div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
    </div>
    <div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
    </div>
  </div>
  <div class="heroSubP">
    <p>介绍</p>
  </div>
  <div class="hero">
    <div class="heroT">
      <h2>Fuys</h2>
      <h2>Fuys</h2>
    </div>
  </div>
  <div class="mountains">
    <div></div>
    <div></div>
    <div></div>
  </div>
  <div class="hero-spacer"></div>
  <div class="content-section">
  <p class="subt">介绍</p>


  <p class="subp">csdn地址:https://blog.csdn.net/m0_73918768?type=blog

     </p>
</div>
  
</body>

<script>
    const canvas = document.getElementById('particleCanvas');
const ctx = canvas.getContext('2d');

// Initial canvas size
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

let particles = [];
let particleCount = calculateParticleCount();

class Particle {
    constructor() {
        this.reset();
        this.y = Math.random() * canvas.height;
        this.fadeDelay = Math.random() * 600 + 100;
        this.fadeStart = Date.now() + this.fadeDelay;
        this.fadingOut = false;
    }

    reset() {
        this.x = Math.random() * canvas.width;
        this.y = Math.random() * canvas.height;
        this.speed = Math.random() / 5 + 0.1;
        this.opacity = 1;
        this.fadeDelay = Math.random() * 600 + 100;
        this.fadeStart = Date.now() + this.fadeDelay;
        this.fadingOut = false;
    }

    update() {
        this.y -= this.speed;
        if (this.y < 0) {
            this.reset();
        }

        if (!this.fadingOut && Date.now() > this.fadeStart) {
            this.fadingOut = true;
        }
        
        if (this.fadingOut) {
            this.opacity -= 0.008;
            if (this.opacity <= 0) {
                this.reset();
            }
        }
    }

    draw() {
        ctx.fillStyle = `rgba(${255 - (Math.random() * 255/2)}, 255, 255, ${this.opacity})`;
        ctx.fillRect(this.x, this.y, 0.4, Math.random() * 2 + 1);
    }
}

function initParticles() {
    particles = [];
    for (let i = 0; i < particleCount; i++) {
        particles.push(new Particle());
    }
}

function animate() {
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    particles.forEach(particle => {
        particle.update();
        particle.draw();
    });
    requestAnimationFrame(animate);
}

function calculateParticleCount() {
    return Math.floor((canvas.width * canvas.height) / 6000);
}

function onResize() {
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    particleCount = calculateParticleCount();
    initParticles();
}

window.addEventListener('resize', onResize);

initParticles();
animate();

</script>

猜拳

和电脑猜拳
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-content: center;
  font-family: system-ui, sans-serif;
  grid-template-columns: 1fr 1fr;
  gap: 2em;
  overflow-x: clip;
}
h2 {
  font-weight: 100;
  font-size: 2rem;
  text-align: center;
}
.choices, .computer {
  display: grid;
  justify-content: center;
  gap: 3em;
}
.btns {
  position: relative;
  border-radius: 100vmax;
  border: 1px solid #1f202050;
  width: 10em;
  aspect-ratio: 1;
}
.choices button {
  position: absolute;
  offset-path: border-box;
  font-size: 4rem;
  margin: 5px;
  border: none;
  background: #E1F8DC;
  cursor: pointer;
  transition: transform 0.3s ease-in-out;
  aspect-ratio: 1;
  border: 1px solid #1f202030;
  border-radius: 100vmax;
  offset-rotate: 0deg;
}
#rock {
  offset-distance: 0%;
}
#paper {
  offset-distance: calc(60 / 180 * 100%);
}
#scissors {
  offset-distance: calc(120 / 180 * 100%);
}
.choices button:hover {
  transform: scale(1.2);
}
#result {
  font-size: 1.3rem;
  margin-top: 2em;
  min-height: 3em;
  text-align: center;
  grid-column: span 2;
}
#animation {
  font-size: 4rem;
  border: 1px solid #1f202030;
  border-radius: 100vmax;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  background-image: repeating-conic-gradient(#E1F8DC 0deg 10deg, #0000 10deg 20deg);
  transition: background-color 0.5s ease;
}
@keyframes fireworks {
  0% {
    opacity: 1;
    transform: scale(0);
  }
  80% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}
.firework {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, white 0%, red 40%, yellow 60%, rgba(255, 255, 255, 0) 100%);
  animation: fireworks 1s ease-out forwards;
}
#fireworks-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

</style>
</head>

<body>
  <div class="choices">
    <h2>选择出拳</h2>
    <div class="btns">
      <button id="rock">&#x270A;</button>
      <button id="paper">&#x270B;</button>
      <button id="scissors">&#x270C;&#xFE0F;</button>
    </div>
  </div>
  <div class="computer">
    <h2>电脑出拳</h2>
    <div id="animation">&#x270A;</div>
  </div>
  <div id="result"></div>
  <div id="fireworks-container"></div>
</body>
<script>
document.addEventListener("DOMContentLoaded", function () {
  const choices = ["rock", "paper", "scissors"];
  const emojiMap = {
    rock: "✊",
    paper: "✋",
    scissors: "✌️"
  };
  const animationContainer = document.getElementById('animation');
  let animationInterval;

  document.getElementById("rock").addEventListener("click", function () {
    playGame("rock");
  });

  document.getElementById("paper").addEventListener("click", function () {
    playGame("paper");
  });

  document.getElementById("scissors").addEventListener("click", function () {
    playGame("scissors");
  });

  function playGame(playerChoice) {
    const computerChoice = choices[Math.floor(Math.random() * choices.length)];
    const animationDiv = document.getElementById("animation");
    const resultDiv = document.getElementById("result");

    clearInterval(animationInterval);
    let currentIndex = 0;

    animationInterval = setInterval(() => {
      animationDiv.textContent = emojiMap[choices[currentIndex]];
      currentIndex = (currentIndex + 1) % choices.length;
    }, 100);

    setTimeout(() => {
      clearInterval(animationInterval);
      animationDiv.textContent = emojiMap[computerChoice];
      displayResult(playerChoice, computerChoice);
    }, 1500);
  }

  function displayResult(playerChoice, computerChoice) {
    let result = "";

    if (playerChoice === computerChoice) {
      result = "平局了!";
    } else if (
      (playerChoice === "rock" && computerChoice === "scissors") ||
      (playerChoice === "paper" && computerChoice === "rock") ||
      (playerChoice === "scissors" && computerChoice === "paper")
    ) {
      result = `你赢了! ${emojiMap[playerChoice]} beats ${emojiMap[computerChoice]}.`;
      triggerFireworks();
    } else {
      result = `你输了! ${emojiMap[computerChoice]} beats ${emojiMap[playerChoice]}.`;
      triggerLossBackground();
    }

    document.getElementById("result").textContent = result;
  }

  function triggerFireworks() {
    const fireworksContainer = document.getElementById("fireworks-container");
    fireworksContainer.innerHTML = ""; 

    for (let i = 0; i < 10; i++) {
      const firework = document.createElement("div");
      firework.className = "firework";
      firework.style.left = `${Math.random() * 100}%`;
      firework.style.top = `${Math.random() * 100}%`;
      firework.style.animationDelay = `${Math.random() * 0.5}s`;

      fireworksContainer.appendChild(firework);

      setTimeout(() => {
        firework.remove();
      }, 1000);
    }
  }
  
  function triggerLossBackground() {
        animationContainer.style.backgroundColor = 'red';

        setTimeout(() => {
            animationContainer.style.backgroundColor = '';
        }, 1000);
    }

    function resetBackgroundColor() {
        animationContainer.style.backgroundColor = '';
    }
  
});


</script>
</html>


小球下楼梯(加载动画)

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
:root {
  --size: 4.17vh;
  --main-color: #2B2B2B;
  --border-color: #fff;
  --jump-duration: 1s;
  --stairs-duration: 1s;
}

html, body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: var(--main-color);
}

.window {
  position: relative;
  width: 35.42vh;
  height: 50vh;
  background-color: #fff;
  border-radius: 17.7vh;
  border: 0.42vh solid var(--main-color);
  box-shadow: 0 0 0 1.25vh var(--border-color);
  overflow: hidden;
}

.window:before {
  content: "";
  position: absolute;
  top: calc(50% - 1.5vh);
  left: calc(50% - 0.5vh);
  border-radius: 50%;
  width: var(--size);
  height: var(--size);
  background-image: linear-gradient(to bottom right, #2E3691, #2E3691);
  box-shadow: 0.21vh -0.21vh 0.42vh 0.42vh rgba(0, 0, 0, 0.35),
  inset -0.31vh 0.31vh 0.21vh 0.1vh rgba(0, 0, 0, 0.75);
  animation: jump var(--jump-duration) ease-in-out infinite,
  gradientChange  12s infinite 0.5s;
}

@keyframes jump {
  0%, 100% {
    transform: translateY(-0.20vh);
  }
  50% {
    transform: translateY(-4vh);
  }
}

@keyframes gradientChange {
  0% {
    background-image: linear-gradient(to bottom right, #2E3691, #485A8B);
  }
  8.33% {
    background-image: linear-gradient(to bottom right, #485A8B, #9B2A89);
  }
  16.66% {
    background-image: linear-gradient(to bottom right, #9B2A89, #E6194D);
  }
  25% {
    background-image: linear-gradient(to bottom right, #E6194D, #F31C26);
  }
  33.33% {
    background-image: linear-gradient(to bottom right, #F31C26, #F27E1E);
  }
  41.66% {
    background-image: linear-gradient(to bottom right, #F27E1E, #FFC80D);
  }
  50% {
    background-image: linear-gradient(to bottom right, #FFC80D, #AFCA3E);
  }
  58.33% {
    background-image: linear-gradient(to bottom right, #AFCA3E, #15A14F);
  }
  66.66% {
    background-image: linear-gradient(to bottom right, #15A14F, #5B9E71);
  }
  75% {
    background-image: linear-gradient(to bottom right, #5B9E71, #54C6D3);
  }
  83.33% {
    background-image: linear-gradient(to bottom right, #54C6D3, #0CAAE3);
  }
  100% {
    background-image: linear-gradient(to bottom right, #0CAAE3, #2E3691);
  }
}


.stairs {
  position: absolute;
  width: 100%;
  right: -100%;
  top: 10.42vh;
  animation: stairs var(--stairs-duration) linear infinite;
}

@keyframes stairs {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(4.17vh, -4.17vh);
  }
}

.stairs span {
  position: absolute;
  top: calc(var(--i) * var(--size));
  right: calc(var(--i) * var(--size));
  width: 100%;
  min-height: var(--size);
  background-color: var(--main-color);
  border-bottom: 0.42vh solid var(--border-color);
  border-top-left-radius: 0.63vh;
}

</style>
</head>

<body>
  <div class="window">
    <div class="stairs">
        <span style="--i:1"></span>
        <span style="--i:2"></span>
        <span style="--i:3"></span>
        <span style="--i:4"></span>
        <span style="--i:5"></span>
        <span style="--i:6"></span>
        <span style="--i:7"></span>
        <span style="--i:8"></span>
        <span style="--i:9"></span>
        <span style="--i:10"></span>
    </div>
</div>
</body>
<script>

</script>
</html>


更改鼠标指针(有尾巴的小黑球)

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
:root {
  --cursor-size: 28px;
  --bg: #FAF7EE;
}

.page-wrap {
  background: var(--bg);
  min-height: 100vh;
}

#cursor {
  position: fixed;
  top: calc(var(--cursor-size) * -0.5);
  left:  calc(var(--cursor-size) * -0.5);
  pointer-events: none;
  mix-blend-mode: difference;  
  filter: url(#goo);
}

.cursor-circle {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cursor-size);
  height: var(--cursor-size);
  border-radius: var(--cursor-size);
  background: var(--bg);
  transform-origin: center center;
}

body {
  overflow-x: hidden;
}

h1 {
  margin: 0;
  padding: 50px;
  text-align: center;
  font-size: 48px;
  line-height: 1;
  font-family: sans-serif;
  text-transform: uppercase;
  user-select: none;
}

.goo {
  display: none;
}
</style>
</head>

<body>
  <svg xmlns="http://www.w3.org/2000/svg" class="goo" version="1.1" width="100%">
    <defs>
        <filter id="goo">
            <feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur"></feGaussianBlur>
            <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 35 -15" result="goo"></feColorMatrix>
            <feComposite in="SourceGraphic" in2="goo" operator="atop"></feComposite>
        </filter>
    </defs>
</svg>

<div class="page-wrap">
  <h1>Fluid<br>Motion</h1>
</div>


<div id="cursor"></div>
</body>
<script>
console.clear();

const TAIL_LENGTH = 20;

const cursor = document.getElementById('cursor');

let mouseX = 0;
let mouseY = 0;

let cursorCircles;
let cursorHistory = Array(TAIL_LENGTH).fill({x: 0, y: 0});

function onm ouseMove(event) {
  mouseX = event.clientX;
  mouseY = event.clientY;
}

function initCursor() {
  for (let i = 0; i < TAIL_LENGTH; i++) {
    let div = document.createElement('div');
    div.classList.add('cursor-circle') ;
    cursor.append(div);
  }
  cursorCircles = Array.from(document.querySelectorAll('.cursor-circle'));
}

function updateCursor() {  
  cursorHistory.shift();
  cursorHistory.push({ x: mouseX, y: mouseY });
    
  for (let i = 0; i < TAIL_LENGTH; i++) {
    let current = cursorHistory[i];
    let next = cursorHistory[i + 1] || cursorHistory[TAIL_LENGTH - 1];
    
    let xDiff = next.x - current.x;
    let yDiff = next.y - current.y;
    
    current.x += xDiff * 0.35;
    current.y += yDiff * 0.35;
    cursorCircles[i].style.transform = `translate(${current.x}px, ${current.y}px) scale(${i/TAIL_LENGTH})`;  
  }
  requestAnimationFrame(updateCursor)
}

document.addEventListener('mousemove', onm ouseMove, false);

initCursor();
updateCursor();
</script>
</html>


标签:em,100%,nth,HTML,background,child,div,好玩,页面
From: https://blog.csdn.net/m0_73918768/article/details/142000807

相关文章

  • html的表单和初始js
    1.表单是html常用的一类,我们平时使用的收集账号密码填写信息都是表单,标签是form,含有属性action和method,action确定表单接受数据的地址,不写默认为网页本身.method有两种收集方式,"post"和"get",其中默认方式为get,但是get对接收信息的大小有限制,post没有2.收集时会使用inp......
  • 【Azure Developer】上手 The Best AI Code "Cursor" : 仅仅7次对话,制作个人页面原型,
    AICode时代早已开启,自己才行动。上手一试,让人惊叹。借助这感叹的情绪,把今天操作Cursor的步骤记录下来,也分享给大家。推荐大家上手一试,让你改变! 准备阶段下载Cursor(https://www.cursor.com/),点击右上角“Download”下载exe安装文件。安装后,桌面会有一个Cursor图表。双击启动! ......
  • 【Azure Developer】上手 The Best AI Code "Cursor" : 仅仅7次对话,制作个人页面原型,
    AICode时代早已开启,自己才行动。上手一试,让人惊叹。借助这感叹的情绪,把今天操作Cursor的步骤记录下来,也分享给大家。推荐大家上手一试,让你改变! 准备阶段下载Cursor(https://www.cursor.com/),点击右上角“Download”下载exe安装文件。安装后,桌面会有一个Cursor图表。......
  • 【Qt】Qt与Html网页进行数据交互
    前言:此项目使用达梦数据库,以Qt制作服务器,Html制作网页客户端界面,可以通过任意浏览器访问。1、Qt与网页进行数据交互1.1、第一步:准备qwebchannel.js文件直接在qt的安装路径里复制即可1.2、第二步:在Qt的.pro文件加载webchannel组件在.pro文件添加如下组件:QT+=c......
  • MASM32+ HTML & JavaScript,好搭档
    哪个编程工具让你的工作效率翻倍?在日益繁忙的工作环境中,选择合适的编程工具已成为提升开发者工作效率的关键。不同的工具能够帮助我们简化代码编写、自动化任务、提升调试速度,甚至让团队协作更加顺畅。那么,哪款编程工具让你的工作效率翻倍?是智能的代码编辑器,强大的版本控制工具,还是......
  • HTML 转 PDF API 接口
    HTML转PDFAPI接口网络工具/文件处理支持网页转PDF高效生成PDF/提供永久链接。1.产品功能超高性能转换效率;支持将传递的HTML转换为PDF,支持转换HTML中的CSS格式;支持传递网站URL,直接转换页面成对应的PDF文件;转换后的PDF提供永久存储文件地址;全接口......
  • [HarmonyOS Next示例代码]流畅滑动页面
    HarmonyOS next示例代码全集PageSlip:本项目是一个基于ArkTS的应用程序,基于伙伴高频使用场景,构建复杂的流畅滑动页面,滑动时不丢帧。流畅滑动页面简介本项目是一个基于ArkTS的应用程序,基于伙伴高频使用场景,构建复杂的流畅滑动页面,滑动时不丢帧。效果预览工程目录├......
  • HTML 下一页功能实现:增强网站导航的简便方法
    在如今的互联网环境中,网站的用户体验显得尤为重要,尤其是在用户浏览网页时,良好的导航功能能极大提升用户的满意度。HTML的“下一页”功能作为增强网站导航的重要手段之一,可以帮助用户轻松地跳转到后续内容,提高浏览效率。如何在网页中实现这一功能,并让用户感受到其带来的便捷呢?HTML......
  • Java 实现下一页功能:后端驱动的页面导航解决方案
    在Ja开发中,实现“下一页”功能是分页技术中的一个重要环节,尤其是在处理大量数据时。对于后端驱动的页面导航解决方案,核心思想是通过服务器来处理分页逻辑,确保前端能够高效获取到数据。这不仅可以减轻前端的负担,还能提高整体系统的性能和用户体验。分页功能的基础概念分页是将......
  • WordPress独立资源下载页面插件美化版
    插件介绍:xydown是一款wordpress的独立下载页面插件,主要适用于wp建站用户使用,有些用户在发布文章的时候想要添加一些下载资源,使用这款插件可以把下载的内容独立出来,支持添加本地下载或者百度网盘蓝奏网盘的网址,并且可以自定义文件信息,包括设置文件名称、文件大小、更新日志......