위코드 사전스터디 1주차 자기소개 페이지 만들기를 위한 CSS 공부
CSS is for styling
-Inline: located in html tags, inside the body tag
-Internal: a better way to apply a particular elements all at once across all webpage. by using < style> < /style>
-External: to have single location(folder) where changing the code gets reflected across all the pages
by adding tag below to all your pages, style gets refelcted
you don't need < style> tag anymore
<link rel="stylesheet" href="css/style.css">
file hirearchy is important. /root (later on when JS)
h1 { color: red;
}
selctor { property: value; }
Best practice: put your "properties" in alphabetical order
name{ }
.name {}
-Class is used to group, behave the similar style
-any html can have more than one class, but it can have only one id
<img class="apple" src=" img address">
*/css/*
.apple {
background-color: red;
}
<img class="laptop circular" src="https://" alt="laptop">
-any html elements can have more than one class
-avobe tag has two class names as laptop and circular
'#' name{}
-pound sign, name and curly bracket
-id only a single one of them on a particular page, unique! Can be used only once
When to use id or class?
-Div is for structure, content division element, split up each boxes separately
-Div doesn't do anything unless you use "CSS" with it
height
width
px or %
You can see the box clearly, by putting distictive colour on your div
it determines how each html elements show up and lay out on the page
width, height
margin, border, padding
{ border : solid; }
{ border-width : 5px; }
{ border-width : 5px 10px 20px 30px; }
{ padding: 10px; }
{ margin: 10px; }
-take up the whole screen by defalut
-but can change the width (flexible)
-can change the display property as inline (but can't change width in this case)
-Blocking any other elements from being on the same line next to it.
< h1>, < p>, < div>, < form>, < ol>
p{
display: inline;
}
not blocking any other, placing next to each other
Can’t change the width
< span>, < img> , < a> (anchors)
<p>a <span class="pro">pro</span>grammer.</p>
occupy the same line, and can set the width
versitile! gives best of both worlds of black and inline
p{
display: inline-block;
}
display none
gets rid of the element, takes it out of the flow,
when you want to make things appear and disapear
e.g. quiz
p{
display: none;
visibility: hidden;
visibility: hidden;
}
Rule of Thumb
e.g.
< div>
< h1> hi < span> hello /// ('span' is nested inside 'h1')
div
h1
span
screen towards the viewer
parent to children
top to bottom of the hierarchy
HTML is by default 'static'
-position the element we select relative
to how it would have been positioned had it been static
-adding a margin relative to where it should have been (like a ghost)
-Doesn't affect any others
Coordinates properties (clockwise) : top right bottom left
.red{
position: relative;
left: 20px;
}
similar to margin
pushed from the original position
-positioning the element relative to its parent (like body element)
-adding a margin relative to its parent element
-it affects the flow of your html! (can take it out of its flow)
-much easier moving things around! being relative to 'body'
-parent doesn't need to be body, it can be any other parent element
-combination of relative and absolute,
using container to fine tune the position (like grey square)
div will be fixed as user scroll through your website.
side bar etc
as long as inside parent(this e.g. is body), inline-block
body {
1. text-align: center;
2. margin: 0 auto 0 auto
}
1.float: texts wrap around the image
-only use it when really really necessary for text to wrap around the image,
don't use it for positioning as it's likely cause issues.
.img {
float: left;
}
2.clear
e.g.
:hover (change the state when mouse over)
img:hover {
background-color: gold;
/ comment /
character * : Asterisk
/forward slash
from Udemy course 'The Complete Python Pro Bootcamp for 2021 by Dr. Angel Yu'