首页 > 编程语言 >在线直播源码,CSS磨砂玻璃效果和渐变主题色文字

在线直播源码,CSS磨砂玻璃效果和渐变主题色文字

时间:2023-10-09 14:11:06浏览次数:56  
标签:palette min hsl 60% 源码 background 磨砂玻璃 CSS 255

在线直播源码,CSS磨砂玻璃效果和渐变主题色文字

HTML

 

<div class="card">
  <h2 class="gradient">
  </h2>
  <div>
    <p>.welcome{</p>
    <p class="indent">"CSDN:lqj_本人"</p>
    <p class="indent">
    <p>}</p>
  </div>
  <a href="#" class="gradient">
</div>

CSS

 

body {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
width: 100vw;
min-height: 100vh;
background: url(https://img0.baidu.com/it/u=1049144354,3589714554&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800) no-repeat;
background-size: cover;
}
 
.card {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 20px;
width: 300px;
height: 400px;
box-shadow: 20px 20px 50px rgba(0, 0, 0, 0.5);
border-top: 1px solid rgba(255, 255, 255, 0.1);
border-left: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 15px;
background: rgba(255, 255, 255, .9);
 
//   background: rgba(255, 255, 255, .3);
//   backdrop-filter: blur(20px) brightness(150%);
@supports (backdrop-filter: blur(20px) brightness(150%)) {
background: rgba(255, 255, 255, .3);
backdrop-filter: blur(20px) brightness(150%);
}
 
h2 {
font-size: 1.8em;
color: transparent;
-webkit-background-clip: text;
background-clip: text;
}
 
p {
font-size: 1em;
color: #1b263b;
font-weight: 300;
 
&.indent {
text-indent: 1em;
}
}
 
a {
padding: 15px 50px;
border-radius: 30px;
color: white;
text-decoration: none;
font-weight: 500;
// background-image: linear-gradient(
//     45deg,
//     hsl(220deg 67.24% 60%),
//     hsl(333.91deg 50% 60%)
// );
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        transition: filter .5s;
 
&:hover {
filter: brightness(120%);
}
}
}

 

js

 

function rgbToHsl(r, g, b) {
  r /= 255;
  g /= 255;
  b /= 255;
 
  let max = Math.max(r, g, b);
  let min = Math.min(r, g, b);
  let h, s, l = (max + min) / 2;
 
  if (max === min) {
    h = s = 0;
  } else {
    let d = max - min;
    s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
 
    switch (max) {
      case r:
        h = (g - b) / d + (g < b ? 6 : 0);
        break;
      case g:
        h = (b - r) / d + 2;
        break;
      case b:
        h = (r - g) / d + 4;
        break;
    }
 
    h /= 6;
  }
 
  return [h * 360, s * 100, l * 100];
}
const gradientBtn = () => {
const img = new Image();
img.addEventListener('load', function() {
const colorThief = new ColorThief();
let palette = colorThief.getPalette(img, 3);
palette.forEach((item, index) => {
palette[index] = rgbToHsl(...item);
})
// document.getElementById('button').style.backgroundImage = `linear-gradient(
        //     45deg,
        //     hsl(${palette[1][0]}deg 60% 60%),
        //     hsl(${palette[2][0]}deg 60% 60%)
        // )`;
        document.querySelectorAll('.gradient').forEach(el => el.style.backgroundImage = `linear-gradient(
            45deg,
            hsl(${palette[1][0]}deg 60% 60%),
            hsl(${palette[2][0]}deg 60% 60%)
        )`);
        // document.getElementById('button').style.backgroundImage = `linear-gradient(
        //     45deg,
        //     hsl(${palette[1][0]}deg ${palette[1][1]}% ${palette[1][2]}%),
        //     hsl(${palette[2][0]}deg ${palette[2][1]}% ${palette[2][2]}%)
        // )`;
// document.getElementById('button').style.backgroundImage = `linear-gradient(
        //     45deg,
        //     rgb(${palette[1][0]}, ${palette[1][1]}, ${palette[1][2]}),
        //     rgb(${palette[2][0]}, ${palette[2][1]}, ${palette[2][2]})
        // )`;
});
img.crossOrigin = 'anonymous';
img.src = 'https://img0.baidu.com/it/u=1049144354,3589714554&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800 no-repeat';
}
 
gradientBtn(); 

 

以上就是 在线直播源码,CSS磨砂玻璃效果和渐变主题色文字,更多内容欢迎关注之后的文章

 

标签:palette,min,hsl,60%,源码,background,磨砂玻璃,CSS,255
From: https://www.cnblogs.com/yunbaomengnan/p/17751589.html

相关文章

  • [完结16章]React18内核探秘:手写React高质量源码迈向高阶开发
    点击下载——[完结16章]React18内核探秘:手写React高质量源码迈向高阶开发  提取码:8epr手写React高质量源码,迈向高阶开发React18内核探秘:手写React高质量源码迈向高阶开发batching批处理,说的是,可以将回调函数中多个setState事件合并为一次渲染,因此是异步的。解决的问题是......
  • CSS~等待效果实现
    <style>.first-loading-wrp{display:flex;justify-content:center;align-items:center;flex-direction:column;min-height:420px;height:100%;margin-top:150px;}.first-loading-wrp.loadin......
  • scss基础
    官网https://www.sass.hk/guide/变量导入SASS文件静默注释混合器选择器继承style选项if指令for循环each循环while条件function函数文件后缀sass有两种后缀名文件:后缀名为sass,不使用大括号和分号后缀名为scss,这种和我们平时写的css文件格式......
  • CSS常用总结
    重置样式html,body,ul,li,a,p,div{padding:0;margin:0;//设置盒模型box-sizing:border-box;//移除移动端特有的点击高亮效果-webkit-tap-highlight-color:transparent;}body{font-family:"PingFangSC","MicrosoftYaHei","Helve......
  • CSS单位
    CSS常用长度单位px:相对长度单位相对于显示器屏幕分辨率rem:相对长度单位对于根元素(即html元素)font-size计算值的倍数html{font-size:14px;那么14px=1rem28px=2rem即:npx=n/14rem}h3{font-size=2rem;//转换为px即是2*12=24px}vw和vh移动端......
  • Vue学习笔记(七):绑定css样式
      1绑定class样式¶vue为HTML绑定css中的class样式是通过v-bind实现的。  1.1绑定单个class¶把需要绑定的样式class名赋值给一遍变量,然后通过变量v-bind绑定class属性,绑定后的class并不会覆盖原来的class属性,而是与原来的class进行叠加。如下所示,d......
  • 使用postcss-px-to-viewport实现兼容
    为提高页面的兼容性,可使用postcss-px-to-viewport。1.安装依赖"postcss-px-to-viewport":"^1.1.1"2.在vite.config.js导入importpostcssPxToViewportfrom'postcss-px-to-viewport';3.增加css配置,示例如下returndefineConfig({plugins:[vue(),buildTi......
  • SpringBoot+RabbitMQ+Redis 开发一个秒杀系统,细节打满(附源码)
    一、简易版秒杀SeckillProject系统简介开发技术二、实现细节记录1、用户密码两次MD5加密2、分布式session维持会话3、异常统一处理4、页面缓存+对象缓存5、页面静态化6、内存标记+Redis预减库存+RabbitMQ异步处理7、解决超卖8、接口限流三、效果展......
  • .Net析构函数再论(CLR源码级的剖析)
    前言碰到一些问题,发觉依旧没有全面了解完全析构函数。本篇继续看下析构函数的一些引申知识。概述析构函数目前发现的总共有三个标记,这里分别一一介绍下。先上一段代码:internalclassProgram:IDisposable{staticvoidMain(string[]args){StreamReader?......
  • 仿京细菜谱微信小程序源码/云开发菜谱微信小程序源码
        仿京细菜谱微信小程序源码,云开发菜谱微信小程序源码。京细菜谱是一个美食分享网站,提供优质的家常菜谱大全,仿京细菜谱小程序源码为喜欢美食的朋友提供了很多的美食烹饪教程,让您轻松学会做美食。对不同食材和地域的饮食做了不同的分类和详细的做菜方法,分类十分详细,八大菜......