Studio X Help Guide
CSS Basics
Colours, fonts, spacing, layouts and animation.
CSS decides how things look. You write it inside a <style> block (put it at the top of Your Content). Each rule picks some elements with a selector, then lists properties and values in curly braces:
<style>
p { /* selector: every <p> */
color: purple; /* property: value; */
font-size: 15px;
}
</style>You can also style one element directly with a style attribute: <p style="color: purple">. That's handy for quick one-offs, but a <style> block keeps things tidy.
Selectors: picking what to style
| Selector | Picks |
|---|---|
p | every <p> |
.fancy | everything with class="fancy" |
#intro | the one element with id="intro" |
.card p | <p>s inside something with class card |
a:hover | links while the mouse is over them |
h2, h3 | both <h2> and <h3> |
Colours
Colours can be names (tomato), hex codes (#0149cf), or rgb(). Add a fourth number to rgba() for see-through colours. Gradients blend between colours.
Text and fonts
Want a special font? Many free font sites give you a <link> line to paste at the top of your content, then you use the font's name in font-family. Always list a backup font after it, like font-family: "Fancy Font", sans-serif;.
The box model: padding, border, margin
Every element is a box. Padding is space inside the border, border is the line around it, and margin is space outside. border-radius rounds the corners and box-shadow adds a shadow.
Backgrounds
A background can be a colour, a gradient, or a picture. Pictures repeat (tile) by default, very 2006.
Layout: side by side with flexbox
display: flex puts the boxes inside it in a row. gap spaces them out, and flex: 1 makes them share the width.
To center something both ways inside a box, use display: flex; align-items: center; justify-content: center;.
Layout: grids
display: grid is perfect for photo galleries and Top 8s. repeat(auto-fill, minmax(100px, 1fr)) fits as many columns as there's room for, so it works on phones too.
Looking good on phones
Lots of people will see your profile on a phone. A @media rule only applies when the screen is narrow, so you can stack things up:
max-width or % instead), and give pictures max-width: 100%.Hover effects and transitions
Animations
@keyframes describes an animation; animation plays it.
Comments in CSS
Notes in CSS go between /* and */. They're great for remembering what each part does.
Next up
Now that you can style anything, learn how to restyle the parts Xinsto adds: Xinsto Hooks »
