James Sherry PRO
Web Development Tutor and Co-Founder of { The Jump } Digital School
Read later: Nerds guide (by my Design hero Sarah Drasner)
In css we can specify a colour in 7 different ways (N.B. a is for alpha (transparency)):
From a background of neutral lighting (so, grey)...
p {
color: hsl(0, 100%, 50%);
}
/* STRUCTURE: ul > li > p */
ul {
color: rebeccaPurple;
}
li {
color: goldenrod;
}
/* <p> colour will be goldenrod */
/* STRUCTURE: div > p */
/* generic style on ancestor */
div {
color: red;
}
/* directly targeting style */
p {
color: green;
}
/* get the red instead of green */
p.myParagraph {
color: inherit;
}
Generally [text-based and] properties where you'd repeat yourself
Accessibility Check:
Ensure sufficient contrast between foreground & background
Chrome DevTools:
Except for px, these measurements don't hold true on a screen, e.g:
Avoid where possible
But how do you say: 1/3 of the width?
Also, sometimes, we want things to respond to their environment (e.g. screen size and orientation), so...
With image backgrounds the container needs to be the size of the image or greater to see the full image
background: no-repeat center/80% url("../img/image.png");
A way of spatially arranging elements on a page
DAM
River
Log/element 1
Log 2
HTML Injection Order
Log 3
Log 4
'auto' (margin only) works on block level elements to take out the rest of the space on the line with margin and center the element.
As with many CSS properties, box-model props can be targeted individually to a fully granular level. E.g.
margin-left: 20px; border-top-width: 5px;
You got margin collapse:
http://codepen.io/jmsherry/pen/zrvjyd
Solution: put a border around it or padding
Things that go inside text or things that don't need a line of their own. ('Phrasing Content' in html5)
Things that take up whole lines ('Flow Content' in html5)
An inline element will accept margin and padding, but the element still sits inline as you might expect.
Margin and padding will only push other elements away horizontally, not vertically. Although padding will appear vertically, margin does not.
An inline element will not respect height and width declarations.
Block level elements do not sit inline but break past them. By default (without setting a width) they take up as much horizontal space as they can.
For margin: auto to work the element must be displayed block and have a width < 100% of parent.
Use this property with vertical-align: top; to avoid 'staircasing' (article)
Partial Credit
Underlining, centering, indenting & changing case. (http://codepen.io/jmsherry/pen/GowvXy)
Fonts are actually just a massive collection of pictures of letters
That means that some fonts won't have some letters that the controls provide. (See font-weight: 100-900)
(default in dark green)
Separately
.myText {
font-style: italic;
font-variant: small-caps;
font-weight: bold;
font-size: 16px;
line-height: 3;
font-family: cursive;
}
Shorthand Syntax (slash between size & line-height)
.myText {
font: italic small-caps bold 16px/3 "Goudy Bookletter 1911", sans-serif;
}
Font family declarations are comma separated and if they contain numbers or special characters then "" are required
font-family: Gill Sans Extrabold, sans-serif; /* GOOD */
font-family: "Goudy Bookletter 1911", sans-serif; /* GOOD */
font-family: Goudy Bookletter 1911, sans-serif; /* BAD */
Pre-made fonts included as a stylesheet.
For the rest of the lesson, go play with your CV
And remember...
By James Sherry
A basic intro to some CSS properties