Ver ❯
Herramientas SEO
Tamaño del resultado:
668 x 574
×
Cambiar Orientacion
Cambiar tema, Oscuro/Luz
<!doctype html> <html lang="es"> <head> <meta charset="utf-8"> <title>Trucos y efectos de CSS3 - Tutoriales En Linea</title> </head> <body> <style> /* global custom-variables */ /* :root { --r: 51; --g: 51; --b: 51; } */ main { width: 100%; padding: 60px 29px; display: flex; flex-direction: column; align-items: center; } label { display: flex; align-items: center; } input { padding: 0; width: 29px; height: 29px; } div.variables-block { width: 100%; display: flex; justify-content: center; margin-top: 29px; } /* 局部 custom-variables */ div.variables-block > div { --r: 51; --g: 51; --b: 51; } div.variables-block > div::after { content: ""; display: inline-block; width: 52px; height: 52px; background: rgb(var(--r), var(--g), var(--b)); } </style> <main> <label for="color"> Por favor seleccione un color de tema: <input type="color" v-model="value" id="color" /> </label> <div class="variables-block"> <div v-for="(ele, idx) in colorList" :ref="'variable' + idx"> </div> </div> </main> <script> const Color = require('https://tutorialesenlinea.futbolgratis.org/CSS3/color.js'); const INITIAL_COLOR = '#b4a078'; export default { data() { return { value: INITIAL_COLOR, } }, computed: { colorList() { const mainColor = this.value.length === 7 && this.value || INITIAL_COLOR; return this.getColorList(mainColor); } }, methods: { getColorList(val) { const color = Color(val); return Array.from({length: 10}).map((v, i) => { let rgb = color.mix(Color('white'), i / 10); this.$nextTick(() => { const style = this.$refs[`variable${i}`][0].style; style.setProperty('--r', rgb.red()); style.setProperty('--g', rgb.green()); style.setProperty('--b', rgb.blue()); }) }); } } } </script> </body> </html>