Professional Documents
Culture Documents
d to h a
it’s go o
It is very common to dim everything
behind an element to focus
on a certain UI element
EXAMPLE:
As seen on youtube.
h e e n t i r e s c r e e n ,
fill t
}
.dimmed { fro m t o p t o b o t t o m
top: 0;
bottom: 0;
left: 0;
take the element
right: 0; out of the document
position: fixed; flow, unaffected by
scrolling.
background: rgba(0,0,0,0.4);
} use a dark
transparent background
.lightbox {
position: absolute;
z-index: 1; take the element
} out of the document
flow, and put it on top.
LIVE CODE:
https://codepen.io/ohansemmanuel/full/BmXaEO/
You can’t always get all that you need
with the text-underline property.
0 2em/100% 2px
1. This portion of the property declaration
is very important.
2. The shorthand sets both the background
position and size values.
i.e background position / background size.
0 2em/100% 2px
{
background-size
background-position
LIVE CODE:
https://codepen.io/ohansemmanuel/full/mpqryz/
No user wants to click a dozen times
to hit that little button of yours.
EXAMPLE:
o u n e e d t h is, yo u k n o w?
Y
button:before { v e s e t
Yo u m u s t h a
content: ' '; i o n : re la t i v e
posit lf.
position: absolute; on the b ut t o n it s e
top: -35px; p s e u d o
left: -35px;
} position
element
t h e
LIVE CODE:
https://codepen.io/ohansemmanuel/full/qpVjBO/
check the console when you click :)
Don’t just use cursor: pointer.
LIVE CODE:
https://codepen.io/ohansemmanuel/full/PEOOrx/
Sometimes you want to hide an element
BUT still have it accessible to screen
readers.
th e c lip p ro p e r t y O N LY
a b s o lut e o r f ixe d
.sr-only { w o rk s o n
positione d elements
position: absolute;
clip: rect(1px 1px 1px 1px); IE 4 to 7
clip: rect(1px, 1px, 1px, 1px); IE 8+ and other browsers
}
LIVE CODE:
https://codepen.io/ohansemmanuel/full/dJZJdq/
Styling a checkbox can be a pain, but
don’t worry there’s a trick for that.
EXAMPLE:
Emoji Checkboxes
NB
Incase you didn’t know, clicking the label will
also toggle the input ‘checked’ property.
Assuming you’ve rightly set the label’s ‘for’ attribute
}
input[type="checkbox"] {
position: absolute;
clip: rect(1px,1px,1px,1px);
} hide the default
checkbox in an
.
ACCESSIBLE manner
input[type="checkbox"] + label::before {
content: '\2639'; target the
display: inline-block; label’s ::before pseudo
width: 1.2em; element.
height: 1.2em;
margin-right: .5em;
border-radius: .1em;
text-indent: .15em;
line-height: 1.4;
}
LIVE CODE:
https://codepen.io/ohansemmanuel/full/xpPaKd/
This one is subtle. Let me explain.
}
body {
background:
url('http://bit.ly/2xMHeVk')
o u n d i m a g e
0 0/cover;); the B a c k g r
on’body’
}
section {
border: 100px solid rgba(0,0,255,0.36);
background: rgba(142,68,173 ,1);
} Don’t forget the background
The Result
section {
border: 100px solid rgba(0,0,255,0.36);
background-clip: padding-box;
} Hey Background, don’t slide
under the border area.
Only cover the padding area
of the element.
Problem Solved.
LIVE CODE:
https://codepen.io/ohansemmanuel/full/xpPaGr/
If some CSS properties I’ve used here are alien to you,
look them up on codrops CSS reference.
// //_ /
Glad you made it to the end!
1. Now that know these stuff, actually practice them!
much love,
Ohans Emmanuel