Part 2: CSS: AC2070: Web Design & Programming
Part 2: CSS: AC2070: Web Design & Programming
#first-intro {
border-bottom: 2px dashed #fff;
}
text-indent: 20px;
letter-spacing: 5px;
word-spacing: 15px;
line-height: 1.2;
font-style: normal|italic;
font-variant: normal|small-caps;
font-weight: normal|bold|bolder|lighter|200|400|700;
font-size: xx-small|x-small|smaller|small|
medium|large|15px, 1em, 1rem;
line-height: 1.2;
font-family: "Times New Roman", Times, serif;
background-image: url(leaves.jpg);
background-repeat: no-repeat|repeat|repeat-x|
repeat-y;
background-position: left|right|center|20%|10px
top|center|bottom|30%|20px;
background-size: auto|cover|contain|50%;
background-origin: padding-box|border-box|
content-box;
background-clip: border-box|padding-box|
content-box;
background-attachment: scroll|fixed|local;
28 AC2070: Web Design & Programming
Đào Trung Kiên @ MICA Institute & Dept. of Comm. Eng., SEEE, Hanoi Univ. of Science and Technology
Multiple Background Images
Possible to put multiple images together in one background
.multi-bg {
background-image: url(decoration.png),
url(ribbon.png), url(old_paper.jpg);
background-repeat: no-repeat;
background-position: left top,
right bottom, left top;
}
viền
content-box:
Default mode mặc định
Width and height properties include only the content
Actual size (w/h) = content + paddings + borders + margins
width, height = content size
border-box:
Width and height properties include content, padding and
border
Actual size (w/h) = content + margins
w/h + margins
padding-top: 2px;
padding-left: 2rem;
margin-top: 2px;
margin-left: 2rem;
Before After
margin-top: 20px
Content
Content Area
Area
margin-top: 20px
Content Area
Content Area
Containing (outer)
block element
border-top-color: #00ff0080;
border-right-color: rgba(0, 127, 255, 0.5);
border-bottom-color: rgb(0, 127, 255);
border-left-color: #00ff00;
border-width: 2px|medium|thick|thin;
border-width: 1px 0 5px thin;
border-width: 2px thin;
border-right-width: 3px;
border-top-left-radius: 10px;
border-top-right-radius: 10px 30%;
border-image-source: url(border.png);
border-image-slice: 30 20% fill 10;
border-image-width: 10px;
border-image-repeat: repeat|round|stretch|space;
Fixed header
Panel
normally
hidden, and
shown when
mouse
pointer comes
over the
“hamburger
button”
Types of pseudo-classes:
Dynamic pseudo-classes
State pseudo-classes
Range pseudo-classes
Structural pseudo-classes
Matching pseudo-classes
Other pseudo-classes
Examples:
text-shadow: 2px 3px 5px gray;
text-shadow: 1px 1px 1px #000, 3px 3px 5px blue;
Examples:
box-shadow: 2px 3px 5px gray;
box-shadow: 1px 1px 1px #000, 3px 3px 5px blue;
background: linear-gradient(70deg,
blue, pink);
86 AC2070: Web Design & Programming
Đào Trung Kiên @ MICA Institute & Dept. of Comm. Eng., SEEE, Hanoi Univ. of Science and Technology
Linear Gradients: Color Stops
background: linear-gradient(red, yellow,
blue, orange);
background: radial-gradient(red
10px, yellow 30%, #1e90ff 50%);
background: radial-gradient(at 0%
30%, red 10px, yellow 30%, #1e90ff
50%);
background: repeating-linear-gradient(-
45deg, red, red 5px, blue 5px, blue 10px);
background: repeating-radial-
gradient(#e66465, #9198e5 20%);
transform: rotate(45deg);
transform-origin: 0 40%;
div:hover {
width: 300px;
}
Multiple transitions at once:
transition: width 2s, height 1s, transform 1.5s;
Equivalent shorthand:
transition: width 1s linear 2s;
div {
animation-name: example;
animation-duration: 4s;
}
Equivalence
animation-name: example;
animation-duration: 5s;
animation-timing-function: linear;
animation-delay: 2s;
animation-iteration-count: infinite;
animation-direction: alternate;
div:hover {
animation-play-state: paused;
}
110 AC2070: Web Design & Programming
Đào Trung Kiên @ MICA Institute & Dept. of Comm. Eng., SEEE, Hanoi Univ. of Science and Technology
Exercise
Create and style a bouncing ball with animation as in the
following:
<section id="left">…</section>
<section id="main">…</section>
.item {
order: 5;
}
Example:
element {
--main-color: brown;
background-color: var(--main-color);
}
.one {
background-color: var(--color);
}
.two {
--size-2: calc(var(--size) + 5px);
width: calc(var(--size) * 2);
}