CSS3 Material 1
CSS3 Material 1
• Media Queries
• Selectors Level 3
• Color
CSS3 modules
CSS3 is collaboration of CSS2 specifications and new specifications, we can called
this collaboration is module. Some of the modules are shown below
• Selectors
• Box Model
• Backgrounds
• Text Effects
• 2D Transformations
• 3D Transformations
• Animations
• User Interface
#rcorners7 {
border-radius: 60px/15px;
background: #FF0000;
padding: 20px;
width: 200px;
height: 150px;
The following table shows the possible values for Rounded corners as follows −
Values Description
border-top-left-radius Use this element for setting the boarder of top left
corner
border-top-right-radius Use this element for setting the boarder of top right
corner
border-bottom-left- Use this element for setting the boarder of bottom left
radius corner
This property can have three values. The following example uses both the values −
<html>
<head>
<style>
#rcorners1 {
border-radius: 25px;
background: #8AC007;
padding: 20px;
width: 200px;
height: 150px;
#rcorners2 {
border-radius: 25px;
width: 200px;
height: 150px;
#rcorners3 {
border-radius: 25px;
background: url(paper.gif);
background-repeat: repeat;
padding: 20px;
width: 200px;
height: 150px;
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style>
#rcorners1 {
background: #a44170;
padding: 20px;
width: 100px;
height: 100px;
#rcorners2 {
background: #a44170;
padding: 20px;
width: 100px;
height: 100px;
#rcorners3 {
background: #a44170;
padding: 20px;
width: 100px;
height: 100px;
</style>
</head>
<body>
<p id="rcorners1"></p>
<p id="rcorners2"></p>
<p id="rcorners3"></p>
</body>
<body>
#borderimg {
padding: 15px;
Values Description
Following is the example which demonstrates to set image as a border for elements
<html>
<head>
<style>
#borderimg1 {
padding: 15px;
border-image-source: url(/https/www.scribd.com/css/images/border.png);
border-image-repeat: round;
border-image-slice: 30;
border-image-width: 10px;
#borderimg2 {
padding: 15px;
border-image-source: url(/https/www.scribd.com/css/images/border.png);
border-image-repeat: round;
border-image-slice: 30;
border-image-width: 20px;
#borderimg3 {
padding: 15px;
border-image-source: url(/https/www.scribd.com/css/images/border.png);
border-image-repeat: round;
border-image-slice: 30;
border-image-width: 30px;
</style>
</head>
<body>
</body>
</html>
Multi Background
CSS Multi background property is used to add one or more images at a time without
HTML code, We can add images as per our requirement.A sample syntax of multi
background images is as follows −
#multibackground {
background-image: url(/https/www.scribd.com/css/images/logo.png), url(/https/www.scribd.com/css/images/border.png);
padding: 75px;
Values Description
<html>
<head>
<style>
#multibackground {
padding: 75px;
</style>
</head>
<body>
<div id="multibackground">
<h1>www.elearninfotech.com</h1>
<p>Elearninfotech originated from the idea that there exists a class of readers
who respond better to online content and prefer to learn new skills at
their own pace from the comforts of their drawing rooms. The journey commenced
with a single tutorial on HTML in 2006 and elated by the response it generated,
we worked our way to adding fresh tutorials to our repository which now proudly
flaunts a wealth of tutorials and allied articles on
topics ranging from programming languages to web designing to academics and much
more..</p>
</div>
</body>
</html>
#multibackground {
As shown above an example, each image is having specific sizes as 50px, 130px and
auto size.
CSS3 - Colors
CSS3 has Supported additional color properties as follows −
• RGBA colors
• HSL colors
• HSLA colors
• Opacity
HSLA stands for hue, saturation, lightness and alpha. Alpha value specifies the
opacity as shown RGBA. A Sample syntax of HSLA as shown below −
opacity is a thinner paints need black added to increase opacity. A sample syntax of
opacity is as shown below −
#g1 {background-color:rgb(255,0,0);opacity:0.6;}
#g2 {background-color:rgb(0,255,0);opacity:0.6;}
#g3 {background-color:rgb(0,0,255);opacity:0.6;}
<html>
<head>
<style>
#p1 {background-color:rgba(255,0,0,0.3);}
#p2 {background-color:rgba(0,255,0,0.3);}
#p3 {background-color:rgba(0,0,255,0.3);}
</style>
</head>
<body>
<p>RGBA colors:</p>
<p id="p1">Red</p>
<p id="p2">Green</p>
<p id="p3">Blue</p>
</body>
</html>
<html>
<head>
<style>
#g2 {background-color:hsl(120,100%,75%);}
#g3 {background-color:hsl(120,100%,25%);}
</style>
</head>
<body>
<p>HSL colors:</p>
<p id="g1">Green</p>
</body>
</html>
<html>
<head>
<style>
#d1 {background-color:hsla(120,100%,50%,0.3);}
#d2 {background-color:hsla(120,100%,75%,0.3);}
#d3 {background-color:hsla(120,100%,25%,0.3);}
</style>
</head>
<body>
<p>HSLA colors:</p>
<p id="d2">Green</p>
<p id="d3">Green</p>
</body>
</html>
<html>
<head>
<style>
#m1 {background-color:rgb(255,0,0);opacity:0.6;}
#m2 {background-color:rgb(0,255,0);opacity:0.6;}
#m3 {background-color:rgb(0,0,255);opacity:0.6;}
</style>
</head>
<body>
<p>HSLA colors:</p>
<p id="m1">Red</p>
<p id="m2">Green</p>
<p id="m3">Blue</p>
</body>
</html>
CSS3 - Gradients
What is Gradients?
Gradients display the combination of two or more colors as shown below −
Types of gradients
• Linear Gradients(down/up/left/right/diagonally)
• Radial Gradients
Linear gradients
Linear gradients are used to arrange two or more colors in linear formats like top to
bottom
Top to bottom
<html>
<head>
<style>
#grad1 {
height: 100px;
background: -webkit-linear-gradient(pink,green);
background: -o-linear-gradient(pink,green);
background: -moz-linear-gradient(pink,green);
background: -ms-linear-gradient(pink,green);
background: linear-gradient(pink,green);
</style>
</head>
<body>
<div id="grad1"></div>
</body>
</html>
It will produce the following result −
Left to right
<html>
<head>
<style>
#grad1 {
height: 100px;
</style>
</head>
<body>
<div id="grad1"></div>
</body>
</html>
Diagonal
Diagonal starts at top left and right button
<html>
<head>
<style>
#grad1 {
height: 100px;
</style>
</head>
<body>
<div id="grad1"></div>
</body>
</html>
Multi color
<html>
<head>
<style>
#grad2 {
height: 100px;
</style>
</head>
<body>
<div id="grad2"></div>
</body>
</html>
<head>
<style>
#grad1 {
height: 100px;
width: 550px;
</style>
</head>
<body>
<div id="grad1"></div>
</body>
</html>
<head>
<style>
#grad1 {
height: 100px;
width: 550px;
</style>
</head>
<body>
<div id="grad1"></div>
</body>
</html>
CSS3 - shadow
CSS3 supported to add shadow to text or elements.Shadow property has divided as
follows
• Text shadow
• Box Shadow
Text shadow
CSS3 supported to add shadow effects to text. Following is the example to add
shadow effects to text
<html>
<head>
<style>
h1 {
h2 {
h3 {
}
h4 {
color: white;
h5 {
h6 {
p {
color: white;
</style>
</head>
<body>
<h1>Elearninfotech.com</h1>
<h2>Elearninfotech.com</h2>
<h3>Elearninfotech.com</h3>
<h4>Elearninfotech.com</h4>
<h5>Elearninfotech.com</h5>
<h6>Elearninfotech.com</h6>
<p>Elearninfotech.com</p>
</body>
</html>
Box shadow
Used to add shadow effects to elements,Following is the example to add shadow
effects to element
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
padding: 15px;
background-color: red;
</style>
</head>
<body>
</body>
</html>
CSS3 - Text
CSS3 contained several extra features, which is added later on
• text-overflow
• word-wrap
• word-break
Values Description
word-wrap Used to break the line and wrap onto next line
Text-overflow
The text-overflow property determines how overflowed content that is not displayed is
signaled to users. the sample example of text overflow is shown as follows −
<html>
<head>
<style>
p.text1 {
white-space: nowrap;
width: 200px;
overflow: hidden;
text-overflow: clip;
p.text2 {
white-space: nowrap;
width: 200px;
overflow: hidden;
text-overflow: ellipsis;
</style>
</head>
<body>
<b>Original Text:</b>
<p>Elearninfotech originated from the idea that there exists a class of
readers who respond better to online content and prefer to learn new skills at
<b>Text overflow:clip:</b>
a class of readers who respond better to online content and prefer to learn
new skills at their own pace from the comforts of their drawing rooms.</p>
<b>Text overflow:ellipsis</b>
a class of readers who respond better to online content and prefer to learn
new skills at their own pace from the comforts of their drawing rooms.</p>
</body>
</html>
<html>
<head>
<style>
p.text1 {
width: 140px;
word-break: keep-all;
}
p.text2 {
width: 140px;
word-break: break-all;
</style>
</head>
<body>
<p class="text1">Elearninfotech originated from the idea that there exists a class
of
readers who respond better to online content and prefer to learn new skills at
<p class="text2">Elearninfotech originated from the idea that there exists a class
of
readers who respond better to online content and prefer to learn new skills at
their
</body>
</html>
p {
word-wrap: break-word;
}
<html>
<head>
<style>
@font-face {
font-family: myFirstFont;
src: url(/https/www.scribd.com/css/font/SansationLight.woff);
div {
font-family: myFirstFont;
</Style>
</head>
<body>
</body>
</html>
Font’s description
The following list contained all the fonts description which are placed in the @font-face
rule −
Values Description
CSS3 - 2d Transforms
2D transforms are used to re-change the element structure as translate, rotate, scale,
and skew
The following table has contained common values which are used in 2D transforms
Values Description
translate(x,y) Used to transforms the element along with x-axis and y-axis
The following examples are shown the sample of all above properties
Rotate 20 degrees
Box rotation with 20 degrees angle as shown below
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: pink;
div#myDiv {
/* IE 9 */
-ms-transform: rotate(20deg);
/* Safari */
-webkit-transform: rotate(20deg);
/* Standard syntax */
transform: rotate(20deg);
</style>
</head>
<body>
<div>
Elearninfotech.com.
</div>
<div id="myDiv">
Elearninfotech.com
</div>
</body>
</html>
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: pink;
div#myDiv {
/* IE 9 */
-ms-transform: rotate(-20deg);
/* Safari */
-webkit-transform: rotate(-20deg);
/* Standard syntax */
transform: rotate(-20deg);
</style>
</head>
<body>
<div>
Elearninfotech.com.
</div>
<div id="myDiv">
Elearninfotech.com
</div>
</body>
</html>
Skew X axis
Box rotation with skew x-axis as shown below
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: pink;
div#skewDiv {
/* IE 9 */
-ms-transform: skewX(20deg);
/* Safari */
-webkit-transform: skewX(20deg);
/* Standard syntax */
transform: skewX(20deg);
</style>
</head>
<body>
<div>
Elearninfotech.com.
</div>
<div id="skewDiv">
Elearninfotech.com
</div>
</body>
</html>
Skew Y axis
Box rotation with skew y-axis as shown below
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: pink;
div#skewDiv {
/* IE 9 */
-ms-transform: skewY(20deg);
/* Safari */
-webkit-transform: skewY(20deg);
/* Standard syntax */
transform: skewY(20deg);
</style>
</head>
<body>
<div>
Elearninfotech.com.
</div>
<div id="skewDiv">
Elearninfotech.com
</div>
</body>
</html>
CSS3 - 3D transforms
Using with 3d transforms, we can move element to x-axis, y-axis and z-axis, Below
example clearly specifies how the element will rotate
Methods of 3D transforms
Below methods are used to call 3D transforms
Values Description
X-axis 3D transforms
The following an example shows the x-axis 3D transforms
<html>
<head>
<style>
div {
width: 200px;
height: 100px;
background-color: pink;
div#myDiv {
-webkit-transform: rotateX(150deg);
/* Safari */
transform: rotateX(150deg);
/* Standard syntax */
</style>
</head>
<body>
<div>
elearninfotech.com
</div>
<p>Rotate X-axis</p>
<div id="myDiv">
elearninfotech.com.
</div>
</body>
</html>
<html>
<head>
<style>
div {
width: 200px;
height: 100px;
background-color: pink;
div#yDiv {
-webkit-transform: rotateY(150deg);
/* Safari */
transform: rotateY(150deg);
/* Standard syntax */
</style>
</head>
<body>
<div>
elearninfotech.com
</div>
<p>Rotate Y axis</p>
<div id="yDiv">
elearninfotech.com.
</div>
</body>
</html>
Z-axis 3D transforms
The following an example shows the Z-axis 3D transforms
<html>
<head>
<style>
div {
width: 200px;
height: 100px;
background-color: pink;
div#zDiv {
-webkit-transform: rotateZ(90deg);
/* Safari */
transform: rotateZ(90deg);
/* Standard syntax */
</style>
</head>
<body>
<p>rotate Z axis</p>
<div id="zDiv">
elearninfotech.com.
</div>
</body>
</html>
CSS3 - Animation
Animation is process of making shape changes and creating motions with elements.
@keyframes
Keyframes will control the intermediate animation steps in CSS3.
to {background-color: green;}
div {
width: 100px;
height: 100px;
background-color: red;
animation-name: animation;
animation-duration: 5s;
The above example shows height, width, color, name and duration of animation with
keyframes syntax
<head>
<style type="text/css">
h1 {
-moz-animation-duration: 3s;
-webkit-animation-duration: 3s;
-moz-animation-name: slidein;
-webkit-animation-name: slidein;
@-moz-keyframes slidein {
from {
margin-left:100%;
width:300%
to {
margin-left:0%;
width:100%;
@-webkit-keyframes slidein {
from {
margin-left:100%;
width:300%
to {
margin-left:0%;
width:100%;
</style>
</head>
<body>
<h1>Elearninfotech</h1>
<p>this is an example of moving left animation .</p>
<script>
function myFunction() {
location.reload();
</script>
</body>
</html>
<head>
<style type="text/css">
h1 {
-moz-animation-duration: 3s;
-webkit-animation-duration: 3s;
-moz-animation-name: slidein;
-webkit-animation-name: slidein;
@-moz-keyframes slidein {
from {
margin-left:100%;
width:300%
75% {
font-size:300%;
margin-left:25%;
width:150%;
}
to {
margin-left:0%;
width:100%;
@-webkit-keyframes slidein {
from {
margin-left:100%;
width:300%
75% {
font-size:300%;
margin-left:25%;
width:150%;
to {
margin-left:0%;
width:100%;
</style>
</head>
<body>
<h1>Elearninfotech</h1>
<script>
function myFunction() {
location.reload();
</script>
</body>
</html>
Values Description
<html>
<head>
<style>
.multi {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
/* Column gap property */
-webkit-column-gap: 40px;
-moz-column-gap: 40px;
column-gap: 40px;
-webkit-column-rule-style: solid;
-moz-column-rule-style: solid;
column-rule-style: solid;
</style>
</head>
<body>
<div class="multi">
Elearninfotech originated from the idea that there exists a class of readers who
respond
better to online content and prefer to learn new skills at their own pace from the
comforts
of their drawing rooms. The journey commenced with a single tutorial on HTML in
2006 and
elated by the response it generated, we worked our way to adding fresh tutorials to
our
repository which now proudly flaunts a wealth of tutorials and allied articles on
topics
ranging from programming languages to web designing to academics and much more.
</div>
</body>
</html>
For suppose, if user wants to make text as new paper without line, we can do this by
removing style syntax as shown below
.multi {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
-webkit-column-gap: 40px;
-moz-column-gap: 40px;
column-gap: 40px;
CSS3 - Responsive
Responsive structure
Below image shows the responsive structure of web pages.
<head>
</head>
<style>
body {
h1 {
color: #9799a7;
font-size: 14px;
font-weight: bold;
margin-bottom: 6px;
.container:before, .container:after {
content: "";
display: table;
.container:after {
clear: both;
.container {
background: #eaeaed;
margin-bottom: 24px;
*zoom: 1;
.container-75 {
width: 75%;
.container-50 {
margin-bottom: 0;
width: 50%;
border-radius: 6px;
}
section, aside {
background: #2db34a;
color: #fff;
margin: 1.858736059%;
padding: 20px 0;
text-align: center;
section {
float: left;
width: 63.197026%;
aside {
float: right;
width: 29.3680297%;
</style>
<body>
<div class="container">
<section>Section</section>
<aside>Aside</aside>
</div>
<section>Section</section>
<aside>Aside</aside>
</div>
<h1>50% Wide Container</h1>
<section>Section</section>
<aside>Aside</aside>
</div>
</body>
</html>