Problem: Custom Color Picker Control with Styled Swatch
Problem description
Given an HTML page containing a <label> with class color-picker that wraps an <input type="color" class="custom-color"> and the text Choose color, write CSS to:
Remove the default appearance of the color input across browsers.
Set the
.custom-colorsize to32pxby32px, removepaddingandborder, and applycursor: pointer.Use
::-webkit-color-swatch-wrapperto remove any built-inpadding.Style
::-webkit-color-swatchto have a2px solid #cccborderand4pxborder-radius.Use
::-moz-color-swatchto apply the sameborderandborder-radiusfor Firefox.Add a
0.2s easetransition toborder-colorandtransformon the swatch.On
.custom-color:hover, increase the swatchborder-colorto#0066ccand scale it up slightly (scale(1.1)).On
.custom-color:focus, remove theoutlineand apply abox-shadowlike0 0 0 3px rgba(0,102,204,0.3).
Goal
Write CSS rules so that the native color picker displays as a 32px × 32px swatch with custom border, rounded corners, smooth hover scaling, and a focus ring, without relying on JavaScript.
Constraints
Use only CSS (no JavaScript).
Remove all native padding and borders via
appearance: noneand vendor resets.Style both WebKit and Mozilla pseudo-elements to ensure consistent cross-browser control.
Apply transitions on
border-colorandtransformover0.2s ease.Define focus styling via
box-shadowinstead of using outline.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.
Problem: Custom Color Picker Control with Styled Swatch
Problem description
Given an HTML page containing a <label> with class color-picker that wraps an <input type="color" class="custom-color"> and the text Choose color, write CSS to:
Remove the default appearance of the color input across browsers.
Set the
.custom-colorsize to32pxby32px, removepaddingandborder, and applycursor: pointer.Use
::-webkit-color-swatch-wrapperto remove any built-inpadding.Style
::-webkit-color-swatchto have a2px solid #cccborderand4pxborder-radius.Use
::-moz-color-swatchto apply the sameborderandborder-radiusfor Firefox.Add a
0.2s easetransition toborder-colorandtransformon the swatch.On
.custom-color:hover, increase the swatchborder-colorto#0066ccand scale it up slightly (scale(1.1)).On
.custom-color:focus, remove theoutlineand apply abox-shadowlike0 0 0 3px rgba(0,102,204,0.3).
Goal
Write CSS rules so that the native color picker displays as a 32px × 32px swatch with custom border, rounded corners, smooth hover scaling, and a focus ring, without relying on JavaScript.
Constraints
Use only CSS (no JavaScript).
Remove all native padding and borders via
appearance: noneand vendor resets.Style both WebKit and Mozilla pseudo-elements to ensure consistent cross-browser control.
Apply transitions on
border-colorandtransformover0.2s ease.Define focus styling via
box-shadowinstead of using outline.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.