M2 Part7
M2 Part7
CSS - Part 2
Box Model 2
- Border Edge: This is space surrounding the padding edge which acts as a
border for the element content. They have properties such as border-width,
border-height and border-thickness.
- Padding Edge: The free space around the content data and it has
properties such as padding-width, padding-height and padding-thickness.
- Content Edge: where the text, videos and images are displayed. They
have properties such as height, width, background color or image.
Eg: Box Model
div 4
{
margin: 10px 10px 20px 20px; // margin top, right, bottom, left
height: 30px;
weight: 20 px;
border: 25 px;
padding: 30px 40px 50px 60 px;
background-color: yellow;
}
The four pixel values of margin and padding shows the top, right, bottom and left
spacing.
When only three values are given (margin: 10px 20px 30px;) then it refers to top, left
as well as right, and bottom spacing.
When only two values are given (margin: 10px 20px;) then the first value refers to
top as well bottom spacing and the second refers to left as well right.
When only one value is given (margin: 20px;) then all the four takes the same
The border-radius is basically used to bring out a shape for the border i.e., a
5
rounded corner or a circular corner, where the radius is half the value of the
width value. There are four combinations of the border-radius;
{
border-top-left-radius: 10px;
border-top-right-radius: 15px;
border-bottom-left-radius: 10px;
border-bottom-right-radius; 15px;
}
We also can assign a style for the border by selecting it to be dotted, solid,
double, dashed, groove, ridge, inset , outset, none and hidden.
Note: We need to understand that the height and width set for the element
represents only the height and width of the content and not of the box
elements. The complete height or width of the element will be the summation of
the heights of all the four box model component.
height = content height + border height + padding height + margin height
dotted - gives a dotted border 6
The border-style property can be one or different four values (each referring
the border for the top border, right border, bottom border, and the left
border).
Backgrounds 7
Background gradient: There are two categories of gradients, linear gradient and
radial gradient. They have the direction, and colors to be used for gradient as
parameter.
The directions can have the values as to top, to bottom, to right, to left, to diagonal,
angle etc.,
Eg:
9
{
background: linear-gradient(to right, yellow, blue, red);
background: radiant-gradient(yellow 3%, blue 10%, red 12%);
background: radiant-gradient(ellipse, yellow, blue, red);
background: radiant-gradient(closest-side at 40% 60%, yellow, blue, red);
- father-side
- closest-side
- closest-corner
- farthest-corner
10
div
{
background: url(image.jpg);
background-size: 150px 100px;
background-repeat: no-repeat;
background-image: url(image1.jpg), url(image2.jpg), url(image3.jpg);
background-position: right top/ left top/ left bottom…;
background-repeat: repeat / norepeat / repeat-y / repeat-x;
background-attachment: fixed / scroll / local / initial / inherit;
}
Text effects
Text Color
h1 {
letter-spacing: 2px;
}
h2 {
letter-spacing: -2px;
}
17
Line Height
h1 {
word-spacing: 20px;
}
h2 {
word-spacing: -2px;
}