Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 1746

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 62k
Author
Asked: November 25, 20242024-11-25T11:00:15+00:00 2024-11-25T11:00:15+00:00

edición del con CSS

  • 62k

.

de las cosas mas difíciles e interesantes para mi siempre han sido los elementos de HTML de formulario, desde hacer que se vean del mismo modo en todos los navegadores, luchar contra instalar un plugin que hace magia en sus node_modules para ponerle mil elementos encima que se ven hermosos, o jugar para ver hasta donde puede llegar un elemento que cada que sacan nuevo es 'ineditable'

el <input type="color" /> es un elemento que se ve re diferente en todos los navegadores ( ni hablar de su menú contextual ! )

color en Chrome, Safari y Firefox, en ese orden
input color en Chrome, Safari y Firefox

como se medio aprecia en la imagen (salió re chiquita) es un bloque de color dentro de algún contenedor con color de fondo y borde, que ni en su casa han de saber como quisieron alinear

.

homogeneizando el

en CSS es empezar de general a particular, así que comenzando por normalizar el elemento, hay que alinearlo, quitarle el padding, el borde y el color de fondo al contenedor

$height: 40px;  $radius: 2px;  [type="color"] {   display: inline-flex;   vertical-align: bottom;   border: none;   border-radius: $radius;   padding: 0; // para quitar el pading en FF   height: $height;   width: 100%;   cursor: pointer; } 
Enter fullscreen mode Exit fullscreen mode

para quitar el padding en chrome y safari se necesita editar el sub-elemento ::-webkit-color-swatch-wrapper

::-webkit-color-swatch-wrapper {   padding: 0; } 
Enter fullscreen mode Exit fullscreen mode

por ultimo, para editar el bloque de color, necesitamos editar los sub-elementos ::-webkit-color-swatch y ::-moz-color-swatch para quitarles los bordes y redondearlo como necesitemos

::-webkit-color-swatch {   border: 0;   border-radius: $radius; }  ::-moz-color-swatch {   border: 0;   border-radius: $radius; } 
Enter fullscreen mode Exit fullscreen mode

listo! ya se ve igual en todos los navegadores (que estaba probando al menos)

input color homogeneizado

.

ahora vamo a ponerlo buapo

para hacerlo en tarjetas tipo pantone primero hay que agregarle un elemento mas que pueda contener al y al

para quienes no lo hayan utilizado, el es un elemento de html muy bonito de los formularios, al que se le puede conectar su contenido con alguna formula definida en el formulario o en un

con el atributo oninput="colorhex.value=value" se liga el valor del color con el valor del que tenga el id colorhex

<input type="color" value="#6600ff" oninput="colorhex.value=value"> <output id="colorhex">#6600ff</output> 
Enter fullscreen mode Exit fullscreen mode

de esta manera cada que se seleccione un color diferente en el , veremos el valor hexadecimal en el (pa’ poder hacer más rápido el copy&paste)

para crear las tarjetas, agregamos un contenedor para tener en columnas los elementos y y editamos un poco los atributos de ambos para darle el estilo final

$radius: 10px; $height: 220px;  .pantone-card {   background: #fff;   display: grid;   width: $height * 1.25;   border-radius: $radius;   box-shadow: 0 2px 4px #0001;   border: 4px solid #fff; } 
Enter fullscreen mode Exit fullscreen mode

como cambiamos la variable height, el color del quedará del nuevo valor de alto y se ajustará al ancho que tome la tarjeta… únicamente nos resta acomodarle el border-radius de los sub-elementos ::-webkit-color-swatch y ::-moz-color-swatch para que el bloque de color quede redondeado de arriba y abajo quede recto

[type="color"] {   display: inline-flex; // esto ya no se necesita    vertical-align: bottom; // esto tampoco   border: none;   border-radius: $radius;   padding: 0;   height: $height;   width: 100%;   cursor: pointer;    &::-webkit-color-swatch-wrapper {     padding: 0;   }    &::-webkit-color-swatch {     border: 0;     border-radius: $radius $radius 0 0; // arriba redondeado y abajo recto   }    &::-moz-color-swatch {     border: 0;     border-radius: $radius $radius 0 0; // arriba redondeado y abajo recto   } } 
Enter fullscreen mode Exit fullscreen mode

al final nada mas nos resta agregarle los estilos al para que parezca el texto típico de las tarjetas de pantone

output {   display: block;   background: #fff;   font-size: 28px;   padding: 16px;   line-height: 1em;   font-family: 'helvetica', sans-serif;    &:before {     content: 'HEXADECIMAL';     font-size: 14px;     font-weight: bold;     display: block;   } } 
Enter fullscreen mode Exit fullscreen mode

al final tendremos tarjetas de color seleccionable, con los elementos nativos de HTML y
Tarjetas de color seleccionable, con los elementos nativos de HTML

. . .

de referencia, acá dejo el ejemplo corriendo

codepen.io/flkt-crnpio/pen/dygbBxy

codepencsshtmlwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.