CSS NOTES Lawan Sir
CSS NOTES Lawan Sir
1. Inline css: inline css code is written in the operating tag of the html
element by using style attribute.
2. Internal css:internal css is written in the head section of an html
element using <style>
Syntax: <head> <style> tagname{} </style> </head>
3. External css : External css styling can be done by using a external
css file_name.css extension and providing the link between that css
file to html file by <link> tag in the head section of html element.
Syntax: <head>
<link rel=”stylesheet” href=”filename”> </head>
Note: The first priority is inline css.
If,
<style> </style>
<link rel="stylesheet" href="style.css">
Here, the first priority is for external css.
writing-mode: vertical-lr; tag helps to set items vertically
text-orientation: upright; helps to add space between elements
text-transform: uppercase; helps to change texts to uppercase letters.
Outline css key helps to create border between margin and border.
.div+p{
/* it will select the first sibling */ adjacent
}
div>p{
/* it will select all the p's inside the div or it will select the direct child/
}
Div ~ h2{
Adjacent selector
}
span::before{
content: "Before"; //helps to add content beforewards
}
span::after{
content: "After";//helps to add content afterwards
}
p::first-line{
/* changes the first line or highlight it */
}
p::first-letter{
/* changes the first letter.. or highlight it */
}
p::selection{
/* helps to select a particular file/lines */
}
Pixabay is a free website where we could download any picture without having
copyrights.
Transition
ease - specifies a transition effect with a slow start, then fast, then end slowly
(this is default)
linear - specifies a transition effect with the same speed from start to end
ease-in - specifies a transition effect with a slow start
ease-out - specifies a transition effect with a slow end
ease-in-out - specifies a transition effect with a slow start and end
cubic-bezier(n,n,n,n) - lets you define your own values in a cubic-bezier
function
Display
For inline elements the height and width is not applicable but to use
we have to use display: block;.
In display:inline-block; we can give height and width externally and
it will be acceptable that way.It is the combination of block and
inline .
Responsive image
img {
max-width: 100%;
height: auto;
} (it will be helpful for responsiveness)
img {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
} (will be helpful to center the image)
div.polaroid {
width: 80%;
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-bottom: 25px;
}
div.container {
text-align: center;
padding: 10px 20px;
}
</style>
</head>
<body>
<div class="polaroid">
<img src="img_5terre.jpg" alt="5 Terre" style="width:100%">
<div class="container">
<p>Cinque Terre</p>
</div>
</div>
<div class="polaroid">
<img src="lights600x400.jpg" alt="Norther Lights" style="width:100%">
<div class="container">
<p>Northern Lights</p>
</div>
/* </div> This will be helpful for creating a polaroid style image with caption
*/
img:hover {
transform: scaleX(-1);
} //helps to move the image or element to the left or kinda of give the
transformation to the element/image
box-sizing: x y b s color; // where x and y stands for directions, b stands for blur
and s stands for spreading
text-shadow: x y b color;
Responsive text
Set the text size to vw(viewport width)unit. That way the text
size will follow the size of the browser window.
<h1 style="font-size:10vw">Hello World</h1>
Viewport is the browser window size. 1vw = 1% of viewport width. If the viewport is
50cm wide, 1vw is 0.5cm.
Media queries