Swati Lathia

Learning ways

CSS 3 Tutorial

CSS3 Border Property

  • border-bottom-left-radius Property: It adds rounded border to the bottom-left corner of a given element. Values may be : %, pixels
  • border-bottom-right-radius Property: It adds rounded border to the bottom-right corner of a given element. Values may be : %, pixels
  • border-top-left-radius Property: It adds rounded border to the top-left corner of a given element. Values may be : %, pixels
  • border-top-right-radius Property: It adds rounded border to the top-right corner of a given element. Values may be : %, pixels

Example:

<html>
	<head>
		<style>
			#e7{
				border-bottom-left-radius:25px;
				border-top-left-radius:25px;
				border-bottom-right-radius:25px;
				border-top-right-radius:25px;
				border:2px solid lightblue;
			}
		</style>
	</head>
	<body>
		<p id='e7'>Border with radius for each side</p>
	</body>
</html>

Output:

Border with radius for each side

  • border-radius Property: It adds rounded corners (all four) to given element. It is a shorthand property for all the corners.

Example

<html>
	<head>
		<style>
			#e8{
				border-radius:5px;
				border:2px solid magenta;
			}
		</style>
	</head>
	<body>
		<p id='e8'>Border Radius Short hand property for all side</p>
	</body>
</html>

Output:

Border Radius Short hand property for all side

CSS3 Background Property

  • background-size Property : It allows you to specify the size of background images. The size can be specified in lengths, percentages, or by using one of the two keywords: contain or cover. The following example resizes a background image to much smaller than the original image (using pixels)

Example

<html>
	<head>
		<style>
			#p_1{
				border:solid 5px black;
				background:url(stats.png);
				background-size:100px 100px;
				background-repeat:no-repeat;
				padding:100px;
			}
		</style>
	</head>
	<body>
		<p id='p_1'>According to facts & figures, Google is the most popular search engine all over the globe.</p>
	</body>
</html>
  • Contain scales the background image to be as large as possible (but both its width and its height must fit inside the content area). As such, depending on the proportions of the background image and the background positioning area, there may be some areas of the background which are not covered by the background image.
  • Cover scales the background image so that the content area is completely covered by the background image (both its width and height are equal to or exceed the content area). As such, some parts of the background image may not be visible in the background positioning area.

Example

<html>
	<head>
		<style>
			#p1{
				border:solid 5px black;
				height:400px;
				width:500px;
				background:url(flower.png);
				background-size:contain;
				background-repeat:no-repeat;
			}
			#p2{
				border:solid 5px black;
				height:400px;
				width:500px;
				background:url(flower.png);
				background-size:cover;
				background-repeat:no-repeat;
			}
		</style>
	</head>
	<body>
		<p id='p1'>Hello World</p><br><br>
		<p id='p2'>Hello World</p>
	</body>
</html>
  • background-origin Property: It specifies where the background image is positioned. The property takes three different values:
    • border-box – the background image starts from the upper left corner of the border
    • padding-box – (default) the background image starts from the upper left corner of the padding edge
    • content-box – the background image starts from the upper left corner of the content

Example

<html>
	<head>
		<style>
			#p1{
				border:double 10px black;
				padding:50px;
				background:url(flower.jpg);
				background-repeat:no-repeat;
				background-origin:border-box;
			}
			#p2{
				border:double 10px black;
				padding:50px;
				background:url(flower.jpg);
				background-repeat:no-repeat;
				background-origin:padding-box;
			}
			#p3{
				border:double 10px black;
				padding:50px;
				background:url(flower.jpg);
				background-repeat:no-repeat;
				background-origin:content-box;
			}
		</style>
	</head>
	<body>
		<p id=p1>Hello World</p><br><br>
		<p id=p2>Hello World</p><br><br>
		<p id=p3>Hello World</p>
	
	</body>
</html>
  • background-clip Property: It specifies the painting area of the background. It takes three different values:
    • border-box – (default) the background is painted to the outside edge of the border
    • padding-box – the background is painted to the outside edge of the padding
    • content-box – the background is painted within the content box
<html>
	<head>
		<style>
			#p1{
					border: 10px dotted black;
					padding: 35px;
					background: cyan;
			}
			#p2{
					border: 10px dotted black;
					padding: 35px;
					background: cyan;
					background-clip:padding-box;
			}
			#p3{
					border: 10px dotted black;
					padding: 35px;
					background: cyan;
					background-clip:content-box;
			}
			#p4{
					border: 10px dotted black;
					padding: 35px;
					background: cyan;
					background-clip:border-box;
			}
		</style>
	</head>
	<body>
		<p id=p1>Hello World</p><br><br>
		<p id=p2>Hello World</p><br><br>
		<p id=p3>Hello World</p><br><br>
		<p id=p4>Hello World</p>
		
	</body>
</html>

Output:

Hello World



Hello World



Hello World



Hello World

CSS3 Gradient Property

  • CSS3 gradients displays smooth transitions between two or more specified colors. There are three types of gradients:
    • Linear Gradients (moves down/up/left/right/diagonally)
    • Radial Gradients (defined by their center)
    • Conic Gradients (rotated around a center point)

Linear Gradients

  • To create a linear gradient, you have to define at least two colors. These are the colors you want to render smooth transitions among. You can also set a starting point and a direction (or an angle) along with the gradient effect.

Syntax : background-image: linear-gradient(direction, color1, color2, …);

Example : This is default direction : top to bottom linear gradient.

<html>
	<head>
		<style>
			#d1{
				height:100px;
                                width:100px;
				background-image:linear-gradient(pink,purple);
			}
		</style>
	</head>
	<body>
		<p>Linear Gradient - Top to Bottom</p>
		<div id=d1></div><br><br>
	</body>
</html>

Output:

Linear Gradient – Top to Bottom



Example : To render a transition from left to right, do the following

<html>
	<head>
		<style>
			#d2{
			height:100px;
                        width:100px;
			background-image:linear-gradient(to right,pink,purple);
			}
		</style>
	</head>
	<body>
		<p>Linear Gradient - left to right</p>
		<div id=d2></div><br><br>
	</body>
</html>

Output:

Linear Gradient – left to right



Example : To render a transition from left to bottom right(diagonal), do the following

<html>
	<head>
		<style>
		#d3{
		height:100px;
                width:100px;
		background-image:linear-gradient(to bottom right,pink,red);
		}
		</style>
	</head>
	<body>
		<p>Linear Gradient - Top to bottom right</p>
		<div id=d3></div><br><br>
	</body>
</html>

Output:

Linear Gradient – Top to bottom right



  • You can also define an angle, if you don’t want to use predefined directions (to bottom, to top, to right, to left, to bottom right, etc.). A value of 0deg is equivalent to “to top”. A value of 90deg is equivalent to “to right”. A value of 180deg is equivalent to “to bottom”.

Example

<html>
	<head>
		<style>
			#d4{
			height:100px;
                        width:100px;
			background-image:linear-gradient(90deg,pink,red);
                        }
		</style>
	</head>
	<body>
		<p>Linear Gradient 90 Degree - left to right</p>
		<div id=d4></div><br><br>
	</body>
</html>

Output:

Linear Gradient 90 Degree – left to right



  • Multi-color Gradient
  • You can also use more than two colors with specified directions for transition effect. Let us check an example

Example

<html>
	<head>
		<style>
		#d5{
		height:100px;
                width:100px;
		background-image:linear-gradient(orange,pink,purple,red);
		}
		#d6{
		height:100px;
                width:100px;
		background-image:linear-gradient(to right,orange,pink,purple);
		}
		</style>
	</head>
	<body>
		<p>Linear Gradient - Multi color</p>
		<div id=d5></div><br><br>
		<div id=d6></div><br><br>
	</body>
</html>

Output:

Linear Gradient – Multi color





  • You can use transparency in transition effect. For that rgba() is used to define colors & transparency. Transparency value ranges from 0(full transparent) to 1(no transparent/opaque).

Example

<html>
	<head>
		<style>
		#d7{
		height:100px;
                width:100px;
		background-image:linear-gradient(to right,rgba(0,255,0,0.5),rgba(0,0,255,1));
		}
		</style>
	</head>
	<body>
		<p>Linear Gradient - Transparency Effect</p>
		<div id=d7></div><br><br>
	</body>
</html>

Output:

Linear Gradient – Transparency Effect



Repeating Linear Gradient : repeating-linear-gradient() is used to repeat linear gradient

Example

<html>
	<head>
		<style>
		#d8{
		height:100px;
                width:100px;
		background-image: repeating-linear-gradient(red,yellow 10%,green 30%);
		}
		</style>
	</head>
	<body>
		<p>Repeating Linear Gradient</p>
		<div id=d8></div><br><br>
	</body>
</html>

Output:

Repeating Linear Gradient



Radial Gradient

  • A radial gradient is defined by its center. Two colors must be defined to do radial gradient effect.
  • Syntax : background-image: radial-gradient(shape, start-color, …, last-color);
  • Shape may be either circle or ellipse(default).

Example

<html>
	<head>
		<style>
			#d9{
			height:100px;
			width:200px;
			background-image:radial-gradient(red,purple,pink);
			}
			#d10{
			height:100px;
			width:200px;
			background-image:radial-gradient(circle,purple,blue,green);
			}
		</style>
	</head>
	<body>
		<p>Radial Gradient Ellipse (Default Shape)</p>
		<div id=d9></div><br><br>

                <p>Radial Gradient Circle</p>
		<div id=d10></div><br><br>
	</body>
</html>

Output:

Radial Gradient Ellipse (Default Shape)



Radial Gradient Circle



  • Repeating a radial-gradient : The repeating-radial-gradient() function is used to repeat radial gradients

Example

<html>
	<head>
		<style>
			#d11{
			height:200px;
			width:200px;
			background-image:repeating-radial-gradient(pink,purple 20%);
			}
		</style>
	</head>
	<body>
		<p>Repeating Radial Gradient</p>
		<div id=d11></div><br><br>
	</body>
</html>

Output:

Repeating Radial Gradient



Conic Gradients

  • A conic gradient is a gradient with color transitions rotated around a center point. To create a conic gradient you have to define at least two colors.
  • Syntax : background-image: conic-gradient([from angle] [at position,] color [degree], color [degree], …);
  • 0deg is a default angle and center is default position. If no degree is specified, the colors will be spread equally around the center point.
  • Lest us check and example includes Conic Gradient: Three Colors, Five Colors, Three colors with Degree

Example

<html>
	<head>
		<style>
			#d12{
			height:200px;
			width:200px;
			background-image:conic-gradient(pink,purple,green);
			}
			#d13{
			height:200px;
			width:500px;
			background-image:conic-gradient(red, yellow, green,purple,pink);
			}
			#d14{
			height:200px;
			width:500px;
			background-image:conic-gradient(green 45deg,purple 90deg,pink 180deg);
			}
		</style>
	</head>
	<body>
		<p>Conic Gradient three colors</p>
		<div id=d12></div><br><br>
		<p>Conic Gradient five colors</p>
		<div id=d13></div><br><br>
		<p>Conic Gradient three colors with degree</p>
		<div id=d14></div><br><br>
	</body>
</html>

Output:

Conic Gradient three colors



Conic Gradient five colors



Conic Gradient three colors with degree



CSS3 Box-shadow Property

  • It attaches one or more shadows to an element.
  • Syntax : box-shadow: none|h-offset v-offset blur spread color |inset|initial|inherit;

Example

<!DOCTYPE html>
<html>
	<head>
		<style> 
			#d15{
				border: 1px solid;
				padding: 10px;
				box-shadow: 5px 10px;
			}
			#d16{
				border: 1px solid;
				padding: 10px;
				box-shadow: 5px 10px red;
			}
		</style>
	</head>
	<body>
		<p>The box-shadow property of an element - Example 1</p><br>
		<div id="d15">
			<p>Hello Everyone</p>
		</div><br>
		<div id="d16">
			<p>Hello Everyone</p>
		</div><br>
	</body>
</html>

Output:

The box-shadow property of an element – Example 1


Hello Everyone


Hello Everyone


  • Property Values:
  • None : No Shadow is displayed. This is default value.
        <head>
		<style> 
			#d17{
				border: 1px solid;
				padding: 10px;
				box-shadow: None
			}
		</style>
	</head>
	<body>
		<p>The box-shadow property Example - 2</p><br>
		<div id="d17">
			<p>Hello World</p>
		</div>
	</body>

Output:

The box-shadow property Example – 2


Hello World


  • h-offset : This is required. It indicates horizontal offset of the shadow. A positive value puts the shadow on the right side of the box, a negative value puts the shadow on the left side of the box.
  • v-offset : This is required. It indicates vertical offset of the shadow. A positive value puts the shadow below the box, a negative value puts the shadow above the box.
<head>
		<style> 
			#d18{
				border: 1px solid;
				padding: 10px;
				box-shadow:10px 10px red;
			}

                        #d19{
				border: 1px solid;
				padding: 10px;
				box-shadow:-10px -10px red;
			}
		</style>
	</head>
	<body>
	<p>The box-shadow Property : Positive h-offset & v-offset</p><br>
		<div id="d18">
			<p>Hello World</p>
		</div><br><br>

        <p>The box-shadow Property : Negative h-offset & v-offset</p><br>
		<div id="d19">
			<p>Hello World</p>
		</div><br><br>
	</body>
</html>

Output:

The box-shadow Property : Positive h-offset & v-offset


Hello World



The box-shadow Property : Negative h-offset & v-offset


Hello World



  • blur : This is optional. It indicates the blur radius. The higher the number, the more blurred the shadow will be.
<head>
		<style> 
			#d20{
				border: 1px solid;
                                width:200px;
				padding: 10px;
				box-shadow:50px 50px 10px red;
			}
		</style>
	</head>
	<body>
		<p>The box-shadow Property : Blur effect</p>
		<div id="d20">
			<p>Hello World</p>
		</div><br>
	</body>

Output:

The box-shadow Property : Blur effect

Hello World



  • Spread : This is optional. It is a spread radius. A positive value increases the size of the shadow, a negative value decreases the size of the shadow.
<head>
		<style> 
			#d21{
				border: 1px solid;
				padding: 10px;
				box-shadow:50px 50px 10px 20px gray;
                                width:200px;
			}
		</style>
	</head>
	<body>
		<p>The box-shadow Property : Blur effect with spread radius</p>
		<div id="d21">
			<p>Hello World</p>
		</div><br>
	</body>

Output:

The box-shadow Property : Blur effect with spread radius

Hello World





  • Color : This is optional. It is a color of the shadow. The default value is the text color.
  • inset : This is optional. It changes the shadow from an outer shadow (outset) to an inner shadow.
<head>
		<style> 
			#d22{
				border: 1px solid;
				padding: 10px;
                                width:200px;
				box-shadow:10px 10px 50px 10px gray inset;
			}
		</style>
	</head>
	<body>
		<P>The box-shadow Property : Inset</P>
		<div id="d22">
			<p>Hello World</p>
		</div><br>
	</body>

Output:

The box-shadow Property : Inset

Hello World


CSS3 Box Sizing Property

  • This property allows us to include the border & padding in an element’s total width and height.
  • Usually, Actual width of an element = border + padding + width.
  • Actual height of an element = border + padding + height.
  • That means , when we set the width/height of an element, the element sometimes appears bigger than we have set . This is all because of the element’s border and padding are added to the element’s specified width/height. This problem is solved by box-sizing property.
  • box-sizing property allows us to include the padding and border in an element’s total width and height. It defines how the width and height of an element are calculated: should they include padding and borders, or not.
  • Syntax : box-sizing: content-box|border-box ;
  • Here content-box is the default. The width and height properties (and min/max properties) includes only the content. Border and padding are not included.
  • In border-box, the width and height properties (and min/max properties) includes content, padding and border.

Example

<!DOCTYPE html>
<html>
<head>
<style> 
#d23{
  box-sizing: content-box;  
  width: 200px;
  height: 100px;
  padding: 30px;  
  border: 10px solid red;
}
#d24{
  box-sizing: border-box;
  width: 200px;
  height: 100px;
  padding: 30px;  
  border: 10px solid red;
}
</style>
</head>
<body>

    <P>box-sizing: content-box - default value</P>
    <p>Here Width and Height are only applied to the content of the element</p>     <br>

    <div id="d23">
       This div has a width of 200px. 
       But the full width is 200px + 20px (left and right border) + 60px (left       and right padding) = 280px</div><br>

    <p>box-sizing: border-box</p>
    <p>Width and height apply to all parts of the element - content, padding and     borders</p><br>

    <div id="d24">Here, the full width is 300px, no matter what</div><br>

</body>
</html>

Output:

box-sizing: content-box – default value

Here Width and Height are only applied to the content of the element


This div has a width of 200px. But the full width is 200px + 20px (left and right border) + 60px (left and right padding) = 280px

box-sizing: border-box

Width and height apply to all parts of the element – content, padding and borders


Here, the full width is 300px, no matter what

CSS3 Drop-Shadow Property

  • The drop-shadow() is an inbuilt function that is used to apply a filter to an image in order to set the picture’s shadow. Drop-shadow() generates a blurred shadow with a provided offset and color.
  • offset-x: This parameter sets the horizontal offset of an image. The positive value creates the offset to the right side and negative value creates the offset to the left side.
  • offset-y: This parameter sets the vertical offset of an image. The positive value creates the offset to the bottom side and negative value creates the offset to the top side.
  • blur-radius: It sets the value of blur radius. It is an optional parameter.
  • color: It sets the color of drop shadow. Its optional parameter.

Example:

<!DOCTYPE html>
<html>
	<head>
		<style>
		img {
		filter:drop-shadow(-10px 10px 10px rgba(0,0,0));
		}
		</style>
	</head>
	<body>
		<img src='stats.png'>
	</body>
</html>

CSS3 Transform Property (2D)

  • CSS3 2D Transform property can be used to translate, rotate, scale & skew the given element using different methods.

translate()

  • This method is used to move an element from its current position depending on the parameters given for the X-axis and the Y-axis.
  • Syntax : transform : translate (pixels in x, pixels in y)
  • Example : Here, division element is moved 100 pixels in X-axis & 100 pixels in Y-axis.
<html>
	<head>
		<style> 	
			#d25{
				width:100px;
				height:50px;
				background-color:lightblue;
				border:1px solid black;
				transform:translate(10px,10px);
			}
		</style>
	</head>
	<body>
		<div id='d25'>
			Hello World
		</div>
</body>
</html>

Output:

Hello World

translateX()

  • This method is used to move an element from its current position depending on the parameters given for the X-axis.
  • Syntax : transform : translateX (pixels in x)
  • Example : In the following example, division element is moved 200 pixels in X-axis.
<html>
	<head>
		<style> 	
			#d26{
				width:100px;
				height:50px;
				background-color:lightblue;
				border:1px solid black;
				transform:translateX(50px);
			}
		</style>
	</head>
	<body>
		<div id='d26'>
			Hello World
		</div>
</body>
</html>

Output:

Hello World

translateY()

  • This method is used to move an element from its current position depending on the parameters given for the Y-axis.
  • Syntax : transform : translateY (pixels in y)
  • Example : In the following example, division element is moved 100 pixels in Y-axis.
<html>
	<head>
		<style> 	
			#d27{
				width:100px;
				height:50px;
				background-color:lightblue;
				border:1px solid black;
				transform:translateY(50px);
			}
		</style>
	</head>
	<body>
		<div id='d27'>
			Hello World
		</div><br>
</body>
</html>

Output:

Hello World



rotate()

  • This method is used to rotate an element clockwise or counter-clockwise at a given degree. If you want to rotate clockwise, set the degree positive. If you want to rotate anticlockwise, set the degree negative.
  • Syntax : transform : rotate(degree) (degree in +ve or -ve)
  • Example
<html>
	<head>
		<style> 	
			#d28{
				width:100px;
				height:50px;
				background-color:lightblue;
				border:1px solid black;
			}
			#d29{
				width:100px;
				height:50px;
				background-color:lightblue;
				border:1px solid black;
				transform:rotate(180deg);
			}
			#d30{
				width:100px;
				height:50px;
				background-color:lightblue;
				border:1px solid black;
				transform:rotate(-90deg);
			}
		</style>
	</head>
	<body>
		<p>Rotate </p>
		<div id='d28'>
			Hello World
		</div>
		<div id='d29'>
			Hello World
		</div>
		<div id='d30'>
			Hello World
		</div>
</body>
</html>

Output:

Rotate

Hello World


Hello World


Hello World



scale()

  • This method is used to increase or decrease the size of an element depending on the parameters given for the width and height.
  • Syntax : transform : scale (width, height). Width & Height must be numbers like 0,0.5,1,2 etc.
  • Example
<html>
	<head>
		<style> 	
			#d31{
				margin:30px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
			}
			#d32{
				margin: 60px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
				transform: scale(2,2);
			}
		</style>
	</head>
	<body>
		<div id='d31'>
			Normal element
		</div>
		<div id='d32'>
			Double than above element
		</div>
</body>
</html>

Output:

Normal element
Double than above element

scaleX()

  • This method is used to increase or decrease the width of an element.
  • Syntax : transform : scaleX(width)

scaleY()

  • This method is used to increase or decrease the height of an element.
  • Syntax : transform : scaleY(height)
<html>
	<head>
		<style> 	
			#d33{
				margin: 150px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
			}
			#d34{
				margin: 150px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
				transform: scaleX(2);
			}
			#d35{
				margin: 150px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
				transform: scaleY(3);
			}
		</style>
	</head>
	<body>
		<div id='d33'>
			Normal element
		</div>
		<div id='d34'>
			Scale in width
		</div>
		<div id='d35'>
			Scale in height
		</div>
</body>
</html>

Output:

Normal element
Scale in width
Scale in height

skewX()

  • This method skews an element along the X-axis by the given angle.
  • Syntax : transform : skewX (degree)

skewY()

  • This method skews an element along the Y-axis by the given angle.
  • Syntax : transform : skewY (degree)
<html>
	<head>
		<style> 	
			#d36{
				margin: 150px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
			}
			#d37{
				margin: 150px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
				transform: skewX(45deg);
			}
			#d38{
				margin: 150px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
				transform: skewY(45deg);
			}
		</style>
	</head>
	<body>
		<div id='d36'>
			Normal element
		</div>
		<div id='d37'>
			Skew in X-axis
		</div>
		<div id='d38'>
			Skew in Y-axis
		</div>
</body>
</html>

Output:

Normal element
Skew in X-axis
Skew in Y-axis

skew()

  • This method skews an element along the X and Y-axis by the given angles.
  • Syntax : transform : skew (degree in X, degree in Y)
<html>
	<head>
		<style> 	
			#d39{
				margin: 150px;
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
				transform: skew(20deg,20deg);
			}
		</style>
	</head>
	<body>
		<div id='d39'>
			Skew in Both Axis at 20 degree
		</div>
</html>

Output:

Skew in Both Axis at 20 degree

matrix()

  • This method combines all the 2D transform methods into one.
  • It takes six parameters, containing mathematics functions, which allows you to rotate, scale, move (translate), and skew elements.
  • The parameters are : matrix(scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY())
<html>
	<head>
		<style> 	
			#d40{
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
			}
			#d41{
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;	
				transform: matrix(1, -0.3, 0, 1, 0, 0);
			}
			#d42{
				width: 100px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;	
				transform: matrix(1, 0, 0.5, 1, 180, 0);
			}
		</style>
	</head>
	<body>
		<div id='d40'>
			Matrix
		</div><br><br>
		<div id='d41'>
                         Matrix
		</div><br><br>
		<div id='d42'>
			Matrix
		</div>
</body>
</html>

Output:

Matrix


Matrix


Matrix

CSS3 Transform Property (3D)

  • It applies a 3D transformation to an element. Transform property can be used with different methods : rotateX(), rotateY(), rotateZ()

rotateX()

  • It rotates an element around its X-axis at a given degree.

rotateY()

  • It rotates an element around its Y-axis at a given degree.

rotateZ()

  • It  rotates an element around its Z-axis at a given degree.
<html>
	<head>
		<style> 	
			#d{
				width: 200px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;
			}
			#d1{
				width: 200px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;	
				transform:rotateX(180deg);
			}
			#d2{
				width: 200px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;	
				transform:rotateY(180deg);
			}
			#d3{
				width: 200px;
				height: 100px;
				background-color: cyan;
				border: 1px solid black;	
				transform:rotateZ(90deg);
			}
			
		</style>
	</head>
	<body>
		<h1>Matrix</h1>
		<div id=d>
			Hello world
		</div><br>
		<div id=d1>
			Rotate in X direction
		</div><br>
		<div id=d2>
			Rotate in Y direction
		</div>
		<div id=d3>
			Rotate in Z direction
		</div>
</body>
</html>

CSS3 Transition Property

  • CSS3 transitions allows you to change property values smoothly, over a given duration.
  • To create a transition effect, you must specify two things: the CSS3 property you want to add an effect to & the duration of the effect.
  • If the duration part is not specified, the transition will have no effect, because the default value is 0.

transition-property

  • It specifies the name of the CSS3 property the transition effect is for.
  • The transition effect will start when the specified CSS3 property changes.
  • The transition effect could typically occur when a user hover over an element.
  • To get transition effect, you must take transition-duration property.
  • Syntax : transition-property : all | width | height | none | property ;

transition-duration Property

  • It specifies how many seconds (s) or milliseconds (ms) a transition effect takes to complete.
  • Syntax : transition-duration: time;
  • Example : transition-property & transition-duration property
<!DOCTYPE html>
<html>
	<head>
		<style> 
			#d43{
				width: 100px;
				height: 100px;
				background: cyan;
				transition-property:width;
				transition-duration:5s;
			}
			#d43:hover {
				width: 300px;
			}
		</style>
	</head>
	<body>
                <p>This transition takes 5 seconds to complete</p>
                <div id='d43'>Take your mouse here</div>
	</body>
</html>

Output:

This transition takes 5 seconds to complete

Take your mouse arrow here

transition-delay Property

  • It specifies when the transition effect will start. The value is defined in seconds (s) or milliseconds (ms).
  • Syntax : transition-delay: time;

Example:

<!DOCTYPE html>
<html>
	<head>
		<style> 
			#d44{
				width: 100px;
				height: 100px;
				background: cyan;
				transition-property:width;
				transition-duration:5s;
				transition-delay:8s;
			}
			#d44:hover {
				width: 300px;
			}
		</style>
	</head>
	<body>
                <p> After 8 seconds, transition will start</p>
		<div id='d44'>Take your mouse here</div>
	</body>
</html>

Output:

After 8 seconds, transition will start

Take your mouse here

transition-timing-function Property

  • It specifies the speed curve of the transition effect. It allows a transition effect to change speed over its duration.
  • Syntax : transition-timing-function: linear | ease | ease-in | ease-out | ease-in-out.
  • linear : It specifies a transition effect with the same speed from start to end.
  • ease : This is default value. It specifies a transition effect with a slow start, then fast, then end slowly.
  • ease-in : It specifies a transition effect with a slow start.
  • ease-out : It specifies a transition effect with a slow end.
  • ease-in-out : It specifies a transition effect with a slow start and end.

Example:

<!DOCTYPE html>
<html>
<head>
<style> 
#d45,#d46,#d47,#d48,#d49{
  width: 100px;
  height: 100px;
  background: cyan;
  transition: width 1s;
}
#d45 {transition-timing-function:linear;}
#d46 {transition-timing-function:ease;}
#d47 {transition-timing-function:ease-in;}
#d48 {transition-timing-function:ease-out;}
#d49 {transition-timing-function:ease-in-out;}

#d45:hover,#d46:hover,#d47:hover,#d48:hover,#d49:hover {
  width: 250px;
}
</style>
</head>
<body>
<div id="d45">This is linear</div><br>
<div id="d46">This is ease</div><br>
<div id="d47">This is ease-in</div><br>
<div id="d48">This is ease-out</div><br>
<div id="d49">This is ease-in-out</div>
</body>
</html>

Output:

This is linear

This is ease

This is ease-in

This is ease-out

This is ease-in-out

transition Property

  • This is the shorthand property for : transition-property, transition-duration, transition-timing-function & transition-delay property.
  • Depending on the requirements, one or more property values can be used. Always specify transition-duration property.
  • Syntax : transition: property duration timing-function delay
  • The transition effect will start when the specified CSS3 property (width) changes value. So, let us specify a new value for the width property when a user mouses over the <div> element.
<html>
	<head>
		<style> 	
			#d50{
				width: 100px;
				height: 100px;
				background: Cyan;
				transition: width 5s;
			}
			#d50:hover {
				width: 200px;
			}
		</style>
	</head>
	<body>
		<P>Transition in 5 Seconds</P>
		<div id='d50'></div>
        </body>
</html>

Output:

Transition Example

  • Let us see another example changes width in 2 seconds & height in 4 seconds
<html>
	<head>
		<style> 	
			#d51{
				width: 100px;
				height: 100px;
				background: Cyan;
				transition: width 2s, height 4s;
			}
			#d51:hover {
				width: 200px;
				height:200px;
			}
		</style>
	</head>
	<body>
		<P>Transition Example - Width in 2 Seconds & Height in 4 Seconds</P>
		<div id='d51'></div>
</body>
</html>

Output:

Transition Example – Width in 2 Seconds & Height in 4 Seconds

We can also create transition & transformation effect together. Let us see an example

<!DOCTYPE html>
<html>
<head>
<style> 
#d52{
  width: 100px;
  height: 100px;
  background: Cyan;
  transition: width 2s, height 2s, transform 4s;
}
#d52:hover {
  width:200px;
  height:200px;
  transform:rotate(180deg);
}
</style>
</head>
<body>
<div id='d52'>Take your mouse here</div>
</body>
</html>

Output:

Take your mouse here

CSS3 Position Property

Position property specifies the type of positioning method used for an element (static, relative, absolute, fixed, or sticky).

Syntax : position: static|absolute|fixed|relative|sticky;

Elements are then positioned using the top, bottom, left, and right properties. These properties will not work unless the position property is set first. They also work differently depending on the position value.

position: static;

HTML elements are positioned static by default. Static positioned elements are not affected by the top, bottom, left, and right properties.

<!DOCTYPE html>
<html>
<head>
<style>
#d53{
  position: static;
  border: 3px solid blue;
}
</style>
</head>
<body>
<div id='d53'>
             This div element has position: static;
</div>
</body>
</html>

Output:

This div element has position: static;

position: relative;

An element with position:relative; is positioned relative to its normal position. Setting the top, right, bottom, and left properties of a relatively-positioned element will effect to its original position. Other content will not be adjusted to fit into any gap left by the element.

<!DOCTYPE html>
<html>
<head>
<style>
#d54{
  position:relative;
  width:200px;
  left: 30px;
  border: 3px solid blue;
}
</style>
</head>
<body>
<div id='d54'>
         This div element has position: relative;
</div>
</body>
</html>

Output:

This div element has position: relative;

position: fixed;

An element with position:fixed;  is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element. A fixed element does not leave a gap in the page where it would normally have been located. The fixed element in the lower-right corner of the page.

<!DOCTYPE html>
<html>
<head>
<style>
#d55{
  position: fixed;
  top: 0;
  left:0;
  width: 300px;
  border: 3px solid green;
}
</style>
</head>
<body>
<div id='d55'>
 This div element has fixed at the top left corner of the screen
</div>
</body>
</html>

CSS3 Flex-box Property

  • CSS Flexbox, short for Flexible Box Layout, is a layout model in CSS (Cascading Style Sheets) that provides an efficient way to arrange and distribute elements within a container, even when their sizes are unknown or dynamic.
  • It simplifies the process of creating complex layouts and helps with designing responsive and flexible user interfaces.
  • display:flex; is applied to the container element to enable Flexbox behavior.

Example

<!DOCTYPE html>
<html>
<head>
<style>
.fbox {
  display:flex;
  background-color:lightblue;
}
.fbox > div {
  background-color:white;
  margin: 10px;
  padding: 20px;
  font-size: 30px;
}
</style>
</head>
<body>
<p>Look at the following flex container</P>
<div class="fbox">
  <div>CSS1</div>
  <div>CSS2</div>
  <div>CSS3</div>  
</div>
</body>
</html>

Output

Look at the following flex container

CSS1
CSS2
CSS3
  • flex-direction Property: It defines the direction in which the flex items are arranged within the flex container. The possible values for the flex-direction property are:
    • row : This is the default value. It arranges the flex items in a horizontal row from left to right.
    • row-reverse : Similar to row, but arranges the flex items in a horizontal row from right to left.
    • column : Stacks the flex items vertically from top to bottom.
    • column-reverse : Stacks the flex items vertically from bottom to top.

Example

<!DOCTYPE html>
<html>
<head>
<style>
.fbox1 {
  display:flex;
  background-color:lightblue;
  flex-direction:row;
}
.fbox1 > div {
  background-color:white;
  margin: 10px;
  padding: 20px;
  font-size: 30px;
}
</style>
</head>
<body>
<p>This flex container arranges the items in a row</p>
<div class="fbox1">
  <div>CSS1</div>
  <div>CSS2</div>
  <div>CSS3</div>  
</div>
</body>
</html>

Output

This flex container arranges the items in a row

CSS1
CSS2
CSS3

Example : flex-direction : column

<!DOCTYPE html>
<html>
<head>
<style>
.fbox2 {
  display:flex;
  background-color:lightblue;
  flex-direction:column;
}
.fbox2 > div {
  text-align:center;
  background-color:white;
  margin: 15px;
  padding: 20px;
  font-size: 30px;
  line-height:30px;
  width:100px;
  font-size:25px;
}
</style>
</head>
<body>
<p>This lex container arranges the items in a column - top to bottom</p>
<div class="fbox2">
  <div>CSS1</div>
  <div>CSS2</div>
  <div>CSS3</div>  
</div>
</body>
</html>

Output

This lex container arranges the items in a column – top to bottom

CSS1
CSS2
CSS3

Example : flex-direction : column-reverse

<!DOCTYPE html>
<html>
<head>
<style>
.fbox3 {
  display:flex;
  background-color:lightblue;
  flex-direction:column-reverse;
}
.fbox3 > div {
  text-align:center;
  background-color:white;
  margin: 15px;
  padding: 20px;
  font-size: 30px;
  line-height:30px;
  width:100px;
  font-size:25px;
}
</style>
</head>
<body>
<p>This lex container arranges the items in vertically - bottom to top</p>
<div class="fbox3">
  <div>CSS1</div>
  <div>CSS2</div>
  <div>CSS3</div>  
</div>
</body>
</html>

Output

This lex container arranges the items in vertically – bottom to top

CSS1
CSS2
CSS3

Example : flex-direction : row-reverse

<!DOCTYPE html>
<html>
<head>
<style>
.fbox4 {
  display:flex;
  background-color:lightblue;
  flex-direction:row-reverse;
}
.fbox4 > div {
  text-align:center;
  background-color:white;
  margin: 15px;
  padding: 20px;
  font-size: 30px;
  line-height:30px;
  width:100px;
  font-size:25px;
}
</style>
</head>
<body>
<p>This lex container arranges the items in reverse row</p>
<div class="fbox4">
  <div>CSS1</div>
  <div>CSS2</div>
  <div>CSS3</div>  
</div>
</body>
</html>

Output

This lex container arranges the items in reverse row

CSS1
CSS2
CSS3
  • flex-wrap Property : It controls whether the flex items should wrap to the next line or remain on a single line within the flex container when they start to exceed the container’s width.
  • It’s particularly useful when dealing with responsive layouts where you want to adjust the arrangement of items as the available space changes. This property accepts the following values:
    • nowrap (default): This value prevents flex items from wrapping. They will all try to fit on a single line, potentially causing overflow if the container isn’t wide enough to accommodate them.
    • wrap: When set to wrap, flex items will wrap onto the next line as needed when the container becomes too narrow. This is useful for creating responsive layouts where you want items to stack vertically when there isn’t enough horizontal space.
    • wrap-reverse: Similar to wrap, but items wrap onto the next line in reverse order. This means the last item becomes the first item on the next line, and so on.

Example : flex-wrap : nowrap

<!DOCTYPE html>
<html>
<head>
<style>
.fbox5 {
  display:flex;
  background-color:lightblue;
  flex-wrap:nowrap;
}
.fbox5 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>This flex container arranges the items without wrap</p>
<div class="fbox5">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
  <div>D</div>
  <div>E</div>
  <div>F</div>   
</div>
<p>Resize the browser to check</p>
</body>
</html>

Output

This flex container arranges the items without wrap

A
B
C
D
E
F

Resize the browser to check

Example : flex-wrap : wrap

<!DOCTYPE html>
<html>
<head>
<style>
.fbox6 {
  display:flex;
  background-color:lightblue;
  flex-wrap:wrap;
}
.fbox6 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>This flex container arranges the items with wrap</p>
<div class="fbox6">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
  <div>D</div>
  <div>E</div>
  <div>F</div> 
  <div>G</div>
  <div>H</div>
  <div>I</div> 
  <div>J</div>
  <div>K</div>
  <div>L</div>  
</div>
<p>Resize the browser to check</p>
</body>
</html>

Output

This flex container arranges the items with wrap

A
B
C
D
E
F
G
H
I
J
K
L

Resize the browser to check

Example : flex-wrap : wrap-reverse

<!DOCTYPE html>
<html>
<head>
<style>
.fbox7 {
  display:flex;
  background-color:lightblue;
  flex-wrap:wrap-reverse;
}
.fbox7 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>This flex container arranges the items with reverse wrap</p>
<div class="fbox7">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
  <div>D</div>
  <div>E</div>
  <div>F</div> 
  <div>G</div>
  <div>H</div>
  <div>I</div> 
  <div>J</div>
  <div>K</div>
  <div>L</div>  
</div>
<p>Resize the browser to check</p>
</body>
</html>

Output

This flex container arranges the items with reverse wrap

A
B
C
D
E
F
G
H
I
J
K
L

Resize the browser to check

  • flex-flow Property : It is a shorthand property that combines both the flex-direction and flex-wrap properties into a single declaration.

Example

<!DOCTYPE html>
<html>
<head>
<style>
.fbox8 {
  display:flex;
  background-color:lightblue;
  flex-flow:row wrap;
}
.fbox8 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>This flex container arranges the items with row wrap</p>
<div class="fbox8">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
  <div>D</div>
  <div>E</div>
  <div>F</div> 
  <div>G</div>
  <div>H</div>
  <div>I</div> 
  <div>J</div>
  <div>K</div>
  <div>L</div>  
</div>
<p>Resize the browser to check</p>
</body>
</html>

Output

This flex container arranges the items with row wrap

A
B
C
D
E
F
G
H
I
J
K
L

Resize the browser to check

  • justify-content property : It is used to control the alignment and spacing of flex items along the main axis within the flex container.
  • It determines how extra space is distributed when the total width of the flex items is less than the width of the flex container’s main axis.
  • This property accepts several values, each affecting the alignment of the flex items in different ways:
    • flex-start : This is the default value. It aligns the flex items at the start of the main axis, pushing them towards the beginning of the container.
    • flex-end : It aligns the flex items at the end of the main axis, pushing them towards the end of the container.
    • center : It centers the flex items along the main axis within the container.
    • space-between : It distributes the flex items evenly along the main axis, with equal space between them. The first item aligns to the start and the last item aligns to the end.
    • space-around : It distributes the flex items evenly along the main axis with equal space around them. This creates spacing between all items and at the beginning and end of the container.
    • space-evenly : Similar to space-around, it distributes the flex items evenly along the main axis with equal space between items and at the beginning and end, but the spacing is distributed more evenly.

Example : justify-content : center

<!DOCTYPE html>
<html>
<head>
<style>
.fbox9 {
  display:flex;
  background-color:lightblue;
  justify-content:center;
}
.fbox9 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>Center of the container</p>
<div class="fbox9">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
</div>
</body>
</html>

Output

Center of the container

A
B
C

Example : justify-content : flex-start

<!DOCTYPE html>
<html>
<head>
<style>
.fbox10 {
  display:flex;
  background-color:lightblue;
  justify-content:flex-start;
}
.fbox10 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>Beginning of the container - Deafault value</p>
<div class="fbox10">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
</div>
</body>
</html>

Output

Beginning of the container – Deafault value

A
B
C

Example : justify-content : flex-end

<!DOCTYPE html>
<html>
<head>
<style>
.fbox11 {
  display:flex;
  background-color:lightblue;
  justify-content:flex-end;
}
.fbox11 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>End of the container</p>
<div class="fbox11">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
</div>
</body>
</html>

Output

End of the container

A
B
C

Example : justify-content : space-around

<!DOCTYPE html>
<html>
<head>
<style>
.fbox12 {
  display:flex;
  background-color:lightblue;
  justify-content:space-around;
}
.fbox12 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>Space before, between and after items</p>
<div class="fbox12">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
</div>
</body>
</html>

Output

Space before, between and after items

A
B
C

Example : justify-content : space-evenly

<!DOCTYPE html>
<html>
<head>
<style>
.fbox13 {
  display:flex;
  background-color:lightblue;
  justify-content:space-evenly;
}
.fbox13 > div {
  background-color:white;
  text-align:center;
  margin: 10px;
  padding: 10px;
  font-size: 20px;
  width:40px;
}
</style>
</head>
<body>
<p>Even Space distribution</p>
<div class="fbox13">
  <div>A</div>
  <div>B</div>
  <div>C</div> 
</div>
</body>
</html>

Output

Even Space distribution

A
B
C
  • align-items Property : This property is used to control the alignment of flex items in a flex container. The possible values for the align-items property are:
    • stretch (default): This value stretches the flex items to fill the container’s height. If no explicit height is set on the flex items, they will stretch to match the container’s height.
    • flex-start : This value aligns the flex items at the start of the cross-axis. In a row direction container, it aligns items to the top. In a column direction container, it aligns items to the left.
    • flex-end : This value aligns the flex items at the end of the cross-axis. In a row direction container, it aligns items to the bottom. In a column direction container, it aligns items to the right.
    • center : This value centers the flex items along the cross-axis.
    • baseline : This value aligns the flex items such that their baselines are aligned. Baselines are used for aligning text and inline elements within the flex container.
  • The align-items property affects all flex items within a flex container. If you want to control the alignment of a specific item within the container, you can use the align-self property on that individual item.

Example

<!DOCTYPE html>
<html>
<head>
      <style>
		#flex-box1
		{
			width: 250px;
  			height: 250px;
		        border: 1px solid black; 
  			display: flex;
    			align-items:flex-start;
		}
		#flex-box1 div
		{
			flex:1;
  			border: 1px solid black;
  			display: flex;
			align-items:center;
		}
		#flex-box2
		{
			width: 250px;
  			height: 250px;
		        border: 1px solid black; 
  			display: flex;
    			align-items:flex-end;
		}
		#flex-box2 div
		{
			flex:1;
  			border: 1px solid black;
  			display: flex;
			align-items:center;
		}
		#flex-box3
		{
			width: 250px;
  			height: 250px;
		        border: 1px solid black; 
  			display: flex;
    			align-items:center;
		}
		#flex-box3 div
		{
			flex:1;
  			border: 1px solid black;
  			display: flex;
			align-items:center;
		}
		#flex-box4
		{
			width: 250px;
  			height: 250px;
		        border: 1px solid black; 
  			display: flex;
    			align-items:stretch;
		}
		#flex-box4 div
		{
			flex:1;
  			border: 1px solid black;
  			display: flex;
			align-items:center;
		}
		#flex-box5
		{
			width: 250px;
  			height: 2500px;
		        border: 1px solid black; 
  			display: flex;
    			align-items:baseline;
		}
		#flex-box5 div
		{
			flex:1;
  			border: 1px solid black;
  			display: flex;
			align-items:center;
		}
      </style>
   </head>
   <body>
	<p>Item alignment - Flex start</p>
	<div id='flex-box1'>
		<div style='background-color:cyan;min-height:30px;'>CSS</div>
		<div style='background-color:pink;min-height:70px;'>HTML</div>
		<div style='background-color:lightblue;min-height:100px;'>JavaScript</div>
	</div>
	<p>Item alignment - Flex end</p>
	<div id='flex-box2'>
		<div style='background-color:cyan;min-height:30px;'>CSS</div>
		<div style='background-color:pink;min-height:70px;'>HTML</div>
		<div style='background-color:lightblue;min-height:100px;'>JavaScript</div>
	</div>
	<p>Item alignment - center</p>
	<div id='flex-box3'>
		<div style='background-color:cyan;min-height:30px;'>CSS</div>
		<div style='background-color:pink;min-height:70px;'>HTML</div>
		<div style='background-color:lightblue;min-height:100px;'>JavaScript</div>
	</div>
	<p>Item alignment - stretch</p>
	<div id='flex-box4'>
		<div style='background-color:cyan;min-height:30px;'>CSS</div>
		<div style='background-color:pink;min-height:70px;'>HTML</div>
		<div style='background-color:lightblue;min-height:100px;'>JavaScript</div>
	</div>
	<p>Item alignment - baseline</p>
	<div id='flex-box5'>
		<div style='background-color:cyan;min-height:30px;'>CSS</div>
		<div style='background-color:pink;min-height:70px;'>HTML</div>
		<div style='background-color:lightblue;min-height:100px;'>JavaScript</div>
	</div>
</body>
</html>

Output

Item alignment – Flex start

CSS
HTML
JavaScript

Item alignment – Flex end

CSS
HTML
JavaScript

Item alignment – center

CSS
HTML
JavaScript

Item alignment – stretch

CSS
HTML
JavaScript

Item alignment – baseline

This is CSS
This is HTML
This is JavaScript
  • align-content Property : It is used to control the alignment of flex items along the cross-axis (vertical axis) within a flex container. This property is applied to a flex container element and affects the positioning of multiple rows of flex items when they don’t fill up the entire cross-axis space.
  • This property has several possible values:
    • flex-start : This value aligns the flex items to the start of the cross-axis of the container. It creates space at the end if the items don’t fill the entire cross-axis.
    • flex-end : This value aligns the flex items to the end of the cross-axis of the container. It creates space at the start if the items don’t fill the entire cross-axis.
    • center : This value centers the flex items along the cross-axis of the container.
    • space-between : This value evenly distributes the flex items along the cross-axis. The first item aligns with the start, and the last item aligns with the end, with equal spacing between the items.
    • space-around : This value evenly distributes the flex items along the cross-axis with equal spacing on both sides of each item.
    • space-evenly : This value evenly distributes the flex items along the cross-axis with equal spacing between and around the items.
    • stretch : This value stretches the flex items to fill the entire cross-axis of the container.
  • This property becomes relevant when there are multiple rows of flex items within a flex container. If there’s only one row of items or the items occupy the entire cross-axis space, the property’s value might not have a noticeable effect.

Example

<!DOCTYPE html>
<html>
<head>
<style>
#fb1 {
  background-color:white;
  width: 100%;
  height: 300px;
  display: flex;
  flex-wrap: wrap;
  align-content:flex-start;
  border:1px solid;
}
#fb1 div {
  width: 100%;
  height: 40px; 
}
#fb2 {
  background-color:white;
  width: 100%;
  height: 300px;
  display: flex;
  flex-wrap: wrap;
  align-content:flex-end;
  border:1px solid;
}
#fb2 div {
  width: 100%;
  height: 40px; 
}
#fb3 {
  background-color:white;
  width: 100%;
  height: 300px;
  display: flex;
  flex-wrap: wrap;
  align-content:center;
  border:1px solid;
}
#fb3 div {
  width: 100%;
  height: 40px; 
}
#fb4 {
  background-color:white;
  width: 100%;
  height: 300px;
  display: flex;
  flex-wrap: wrap;
  align-content:space-between;
  border:1px solid;
}
#fb4 div {
  width: 100%;
  height: 40px; 
}
#fb5 {
  background-color:white;
  width: 100%;
  height: 300px;
  display: flex;
  flex-wrap: wrap;
  align-content:space-around;
  border:1px solid;
}
#fb5 div {
  width: 100%;
  height: 40px; 
}
#fb6 {
  background-color:white;
  width: 100%;
  height: 300px;
  display: flex;
  flex-wrap: wrap;
  align-content:space-evenly;
  border:1px solid;
}
#fb6 div {
  width: 100%;
  height: 40px; 
}
#fb7 {
  background-color:white;
  width: 100%;
  height: 300px;
  display: flex;
  flex-wrap: wrap;
  align-content:stretch;
  border:1px solid;
}
#fb7 div {
  width: 100%;
  height: 40px; 
}
</style>
</head>
<body>
<p>Content Alignment - Flex start </h1>
<div id="fb1">
  <div style="background-color:cyan;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Content Alignment - Flex end </h1>
<div id="fb2">
  <div style="background-color:cyan;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Content Alignment - Center </h1>
<div id="fb3">
  <div style="background-color:cyan;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Content Alignment - Space Between </h1>
<div id="fb4">
  <div style="background-color:cyan;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Content Alignment - Space Around </h1>
<div id="fb5">
  <div style="background-color:cyan;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Content Alignment - Space Evenly </h1>
<div id="fb6">
  <div style="background-color:cyan;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Content Alignment - Stretch </h1>
<div id="fb7">
  <div style="background-color:cyan;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
</body>
</html>

Output

Content Alignment – Flex start

Content Alignment – Flex end

Content Alignment – Center

Content Alignment – Space Between

Content Alignment – Space Around

Content Alignment – Space Evenly

Content Alignment – Stretch

  • Row-Gap Property : This is used to set the spacing (gap) between rows within the flex items in flex container. This property specifies the size of the vertical gap between adjacent rows.
  • Column-gap Property : This property is used to set the spacing (gap) between columns within the flex items in flex container. It allows you to control the horizontal spacing between columns.
  • Gap Property : This property is used to set the spacing (gap) between rows and columns within the flex items in flex container. It allows you to control the vertical and horizontal spacing as well.

Example

<!DOCTYPE html>
<html>
	<head>
		<style>
		/* Row - Gap property */
			#rgap
			{
				display:flex;
				border:1px solid;
				background-color:beige;
				flex-wrap:wrap;
				row-gap:20px;
			}
			#rgap div
			{
				padding:30px;
				width:50px;
				background-color:lightblue;
				border:1px solid blue;
			}
			/* Column - Gap property */
			#cgap
			{
				display:flex;
				border:1px solid;
				background-color:beige;
				flex-wrap:wrap;
				column-gap:20px;
			}
			#cgap div
			{
				padding:30px;
				width:50px;
				background-color:lightblue;
				border:1px solid blue;
			}
			/* Gap property */
			#gap
			{
				display:flex;
				border:1px solid;
				background-color:beige;
				flex-wrap:wrap;
				gap:10px 50px;/* row column */
			}
			#gap div
			{
				padding:30px;
				background-color:lightblue;
				border:1px solid blue;
			}
		</style>
	</head>
	<body>
		<p>Row Gap</p>
		<div id=rgap>
			<div>1</div>
			<div>2</div>
			<div>3</div>
			<div>4</div>
			<div>5</div>
			<div>6</div>
			<div>7</div>
			<div>8</div>
			<div>9</div>
			<div>10</div>
			<div>11</div>
			<div>12</div>
			<div>13</div>
			<div>14</div>
			<div>15</div>
			<div>16</div>
			<div>17</div>
			<div>18</div>
			<div>19</div>
			<div>20</div>
			<div>21</div>
			<div>22</div>
			<div>23</div>
		</div>
		<p>Column Gap</p>
		<div id=cgap>
			<div>1</div>
			<div>2</div>
			<div>3</div>
			<div>4</div>
			<div>5</div>
			<div>6</div>
			<div>7</div>
			<div>8</div>
			<div>9</div>
			<div>10</div>
			<div>11</div>
			<div>12</div>
			<div>13</div>
			<div>14</div>
			<div>15</div>
			<div>16</div>
			<div>17</div>
			<div>18</div>
			<div>19</div>
			<div>20</div>
			<div>21</div>
			<div>22</div>
			<div>23</div>
		</div>
		<p>Gap - Both Row and Column</p>
		<div id=gap>
			<div>1</div>
			<div>2</div>
			<div>3</div>
			<div>4</div>
			<div>5</div>
			<div>6</div>
			<div>7</div>
			<div>8</div>
			<div>9</div>
			<div>10</div>
			<div>11</div>
			<div>12</div>
			<div>13</div>
			<div>14</div>
			<div>15</div>
			<div>16</div>
			<div>17</div>
			<div>18</div>
			<div>19</div>
			<div>20</div>
			<div>21</div>
			<div>22</div>
			<div>23</div>
		</div>
	</body>
</html>

Output

Row Gap

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Column Gap

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Gap – Both Row and Column

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

overflow Property

  • This property in CSS is used to control what happens when the content of an element overflows its designated area.
  • It specifies how the content that exceeds the dimensions of an element should be displayed.
  • This property is commonly used with block-level elements, such as <div> elements, where the content might extend beyond the element’s visible area.
  • This property can have following values:
  1. visible: This is the default value. Content that overflows the element’s boundaries will be displayed outside the element’s box, potentially overlapping with surrounding content.
  2. hidden: Content that overflows will be clipped and not displayed. It will be hidden from view.
  3. scroll: Scrollbars will be added to the element, allowing users to scroll and see the hidden content. Even if there’s no overflow, scrollbars may still appear but in a disabled state.
  4. auto: Scrollbars will be added only if the content overflows. If there’s no overflow, no scrollbars will be displayed.
  5. clip: The rest of the text will be hidden because the overflow is clipped. It does not allow scrolling, not even programmable scrolling.

Example

<!DOCTYPE html>
<html>
	<head>
		<style>
			body
			{
				background-color:beige;
			}
			#d_auto
			{
				height:150px;
				background-color:lightblue;
			}
			.c_auto
			{
				background-color:white;
				width: 150px;
				height: 100px;
				overflow:auto;
			}
			#d_visibile
			{
				height:150px;
				background-color:lightblue;
			}
			.c_visible
			{
				background-color:white;
				width: 150px;
				height: 100px;
				overflow:visible;
			}
			#d_hidden
			{
				height:150px;
				background-color:lightblue;
			}
			.c_hidden
			{
				background-color:white;
				width: 150px;
				height: 100px;
				overflow:hidden;
			}
			#d_clip
			{
				height:150px;
				background-color:lightblue;
			}
			.c_clip
			{
				background-color:white;
				width: 150px;
				height: 100px;
				overflow:clip;
			}
			#d_scroll
			{
				height:150px;
				background-color:lightblue;
			}
			.c_scroll			
			{
				background-color:white;
				width: 150px;
				height: 100px;
				overflow:scroll;
			}
		</style>
	</head>
	<body>
		<P>This is overflow property :auto </p>
		<div id="d_auto">
			<div class='c_auto'>Hi This is Swati From HJDOSHI Jamnagar.
			Greetings of the Day to all.
			If this content does not fit in given box, then it will create scrollbar.
			</div>
		</div>
		<P>This is overflow property : visible </p>
		<div id="d_visibile">
			<div class='c_visible'>Hi This is Swati From HJDOSHI Jamnagar.
			Greetings of the Day to all.
			This content shows outside the element's box.
			This is default one.
			</div>
		</div>
		<P>This is overflow property : hidden </p>
		<div id="d_hidden">
			<div class='c_hidden'>Hi This is Swati From HJDOSHI Jamnagar.
			Greetings of the Day to all.
			If this content is too lont to fit in, it will be hidden.
			</div>
		</div>
		<P>This is overflow property : clip </p>
		<div id="d_clip">
			<div class='c_clip'>Hi This is Swati From HJDOSHI Jamnagar.
			Greetings of the Day to all.
			If this content is too lont to fit in, it will be clipped.
			</div>
		</div>
		<P>This is overflow property : scroll </p>
		<div id="d_scroll">
			<div class='c_scroll'>Hi This is Swati From HJDOSHI Jamnagar.
			Greetings of the Day to all.
			If this content is too lont to fit in, it will give you 
			a scrollbar.
			</div>
		</div>
	</body>
</html>

Output

This is overflow property :auto

Hi This is Swati From HJDOSHI Jamnagar. Greetings of the Day to all. If this content does not fit in given box, then it will create scrollbar.

This is overflow property : visible

Hi This is Swati From HJDOSHI Jamnagar. Greetings of the Day to all. This content shows outside the element’s box. This is default one.

This is overflow property : hidden

Hi This is Swati From HJDOSHI Jamnagar. Greetings of the Day to all. If this content is too lont to fit in, it will be hidden.

This is overflow property : clip

Hi This is Swati From HJDOSHI Jamnagar. Greetings of the Day to all. If this content is too lont to fit in, it will be clipped.

This is overflow property : scroll

Hi This is Swati From HJDOSHI Jamnagar. Greetings of the Day to all. If this content is too lont to fit in, it will give you a scrollbar.

text-overflow Property

  • This property in CSS is used to control how overflowing text content is displayed within a container when it exceeds its available space. It’s commonly used with elements that have a limited width or height, such as containers with fixed dimensions or single-line text elements.
  • When text overflows its container, the default behavior is for it to be clipped or truncated, meaning that only the portion of text that fits within the container is visible, and the rest is hidden. The text-overflow property allows you to customize this behavior. Here’s how it works:
  • The text-overflow property can have the following values:
  1. clip : This is the default value. It causes the text to be clipped when it overflows the container, and any overflow beyond the container’s boundaries is hidden.
  2. ellipsis : This value adds an ellipsis (“…”) at the end of the text if it overflows the container. This is a common way to indicate to users that there’s more content that’s not fully visible.

Example

<!DOCTYPE html>
<html>
	<head>
		<style> 
			#a 
			{
				width: 100px; 
				border: 1px solid;
				overflow: hidden;
				white-space:nowrap;
				text-overflow:clip;
			}
                        #a:hover
                        {
                               overflow:visible;
                               color:red;
                        }
			#b 
			{
				width: 100px; 
				border: 1px solid;
				overflow: hidden;
				white-space:nowrap;
				text-overflow:ellipsis;
			}
                        #b:hover
                        {
                               overflow:visible;
                               color:red;
                        }
		</style>
	</head>
	<body>
		<p> text-overflow : clip </p>
		<p>Hover over the div below, to see the entire text.</p>
		<div id="a">This is HJDOSHI that will not fit in the box.</div>
		
		<p> text-overflow : ellipsis </p>
		<p>Hover over the div below, to see the entire text.</p>
		<div id="b">This is HJDOSHI that will not fit in the box.</div>		
	</body>
</html>

Output

text-overflow : clip

Hover over the div below, to see the entire text.

This is HJDOSHI that will not fit in the box.

text-overflow : ellipsis

Hover over the div below, to see the entire text.

This is HJDOSHI that will not fit in the box.

Cursor Property

  • This property is used to control the appearance of the mouse cursor when it hovers over an element on a web page.
  • It allows you to define the visual feedback that users get when they interact with different parts of your webpage, indicating the type of action they can perform.
  • The cursor property accepts various values, each representing a different type of cursor. Here are some common values:
  1. auto: This is the default value. The browser determines the appropriate cursor based on the context, such as links or text.
  2. pointer: This value displays a hand cursor, indicating that the element is clickable, like a link or a button.
  3. default: This value displays the standard arrow cursor, indicating a default state.
  4. text: The I-beam cursor appears, indicating that the text can be selected or edited, like in input fields or text areas.
  5. move: The cursor changes to a four-sided arrow, indicating that the element can be dragged/moved.
  6. crosshair: The cursor turns into a crosshair, often used to indicate an area that can be selected.
  7. not-allowed: The cursor becomes a circle with a slash through it, indicating that the specified action is not allowed or not supported.
  8. wait: The cursor turns into a spinning circle or hourglass, indicating that the user should wait, typically used during loading processes.
  9. help: The cursor becomes a question mark, indicating that the user can get help or information about the element.
  10. e-resize, w-resize, n-resize, s-resize: These values indicate that the cursor will change when hovering over the edges of an element, showing the direction in which the element can be resized.
  11. zoom-in: The cursor suggests the potential for zooming in on something.
  12. zoom-out: The cursor implies the possibility of zooming out on something.

Example

<!DOCTYPE html>
<html>
	<head>
		<style>
			.button 
			{
				cursor: pointer;
			}
			.draggable 
			{
				cursor: move;
			}
			.disabled 
			{
				cursor: not-allowed;
			}
			.help 
			{
				cursor: help;
			}
			.auto 
			{
				cursor: auto;
			}
			.default 
			{
				cursor: default;
			}
			.text 
			{
				cursor: text;
			}
			.crosshair
			{
				cursor: crosshair;
			}
			.wait
			{
				cursor: wait;
			}
			.e-resize
			{
				cursor: e-resize;
			}
			.w-resize
			{
				cursor: w-resize;
			}
			.n-resize
			{
				cursor: n-resize;
			}
			.s-resize
			{
				cursor: s-resize;
			}
			.zin
			{
				cursor: zoom-in;
			}
			.zout
			{
				cursor: zoom-out;
			}

</style>
</head>
<body>
	<p class="button">This is pointer</p><br>
	<p class="draggable">This is draggable</p><br>
	<p class="disabled">Disabled is here</p><br>
	<p class="help">Help is here</p><br>
	<p class="auto">This is auto</p><br>
	<p class="default">This is default</p><br>
	<p class="text">This is text</p><br>
	<p class="crosshair">This is Crosshair</p><br>
	<p class="wait">This is wait</p><br>
	<p class="e-resize">This is eastern resize</p><br>
	<p class="w-resize">This is western resize</p><br>
	<p class="n-resize">This is northern resize</p><br>
	<p class="s-resize">This is southern resize</p><br>
	<p class="zin">This is Zoom in</p><br>
	<p class="zout">This is Zoom out</p><br>
</body>

Output

This is pointer


This is draggable


Disabled is here


Help is here


This is auto


This is default


This is text


This is Crosshair


This is wait


This is eastern resize


This is western resize


This is northern resize


This is southern resize


This is Zoom in


This is Zoom out


Visibility Property

  • This property in CSS controls the visibility of an element on a web page. It has two main values: visible and hidden.
  1. visible: This is the default value. When an element’s visibility is set to visible, the element is displayed on the web page as usual. It’s visible to the user and takes up space within the layout.
  2. hidden: When an element’s visibility is set to hidden, the element becomes invisible, but it still occupies space in the layout. In other words, it’s as if the element is there, but it’s just not visible to the user. It won’t be displayed, but it will affect the positioning of other elements around it as if it were visible.
  3. collapse: This particular value is exclusively employed for elements like table rows (<tr>), row groups (<tbody>), columns (<col>), and column groups (<colgroup>). It eliminates a row or column without impacting the overall table arrangement. The area previously occupied by the row or column becomes vacant, allowing for other content to occupy that space.

Example

<!DOCTYPE html>
<html>
	<head>
		<style>
			#a_visible 
			{
				visibility: visible;
			}
			#b_hide
			{
				visibility: hidden;
			}
			table,td
			{
				border:1px solid;
			}
			tr.t_collapse
			{
				visibility:collapse;
			}
		</style>
	</head>
	<body>
		<P>The visibility Property</P>
		<p id="a_visible">This paragraph is visible.</p>
		<p id="b_hide">This is hidden</p>
		<p>This is second paragraph</p>
		<P>Following table has two rows, second row is collapse</p>
		<table>
			<tr>
				<td>HTML</td>
				<td>CSS</td>
			</tr>
			<tr class='t_collapse'>
				<td>C language</td>
				<td>CF</td>
			</tr>
		</table>
	</body>
</html>

Output

The visibility Property

This paragraph is visible.

This is hidden

This is second paragraph

Following table has two rows, second row is collapse

HTML CSS
C language CF

filter Property

  • This property in CSS is used to apply visual effects (such as blurring, grayscale, brightness adjustment, etc.) to elements on a web page.
  • It works by processing the element’s content and altering its appearance based on the specified filter functions.
  • The filter property accepts one or more filter functions, which are separated by spaces. Each filter function performs a specific visual effect on the element.
  • Here are some common filter functions:
  1. blur() : Applies a blur effect to the element, creating a blurred appearance. The higher the value passed to the function, the more pronounced the blur effect.
  2. brightness() : Adjusts the brightness of the element’s content. A value of 1 means no change, values less than 1 darken the content, and values greater than 1 brighten the content.
  3. contrast() : Adjusts the contrast of the element’s content. A value of 1 means no change, values less than 1 decrease the contrast, and values greater than 1 increase the contrast.
  4. grayscale() : Converts the element’s content to grayscale, removing color information.
  5. sepia() : Applies a sepia tone effect to the element’s content, giving it an aged, brownish appearance.
  6. saturate() : Adjusts the saturation of the element’s content. A value of 1 means no change, values less than 1 desaturate the content, and values greater than 1 saturate the content.
  7. hue-rotate() : Rotates the hue of the element’s content. The angle passed to the function determines the degree of rotation.
  8. invert() : Inverts the colors of the element’s content. A value of 0 means no change, and a value of 1 completely inverts the colors.
  9. opacity() : Adjusts the opacity of the element’s content. A value of 1 means no change, and values between 0 and 1 make the content more or less transparent.
  10. drop-shadow() : Applies a drop shadow effect to the element. It takes parameters for horizontal and vertical offset, blur radius, and shadow color.

Example

<!DOCTYPE html>
<html>
<head>
<style>
body 
{
  background-color:beige;
}
#div_img 
{
  height:300px;
  background-color:white;
}
#img1 
{ 
  filter:blur(5px);
}
#img2
{ 
  filter:brightness(150%);
}
#img3
{ 
  filter:contrast(200%);
}
#img4
{ 
  filter:grayscale(100%);
}
#img5
{ 
  filter:sepia(100%);
}
#img6
{ 
  filter:saturate(9);
}
#img7
{ 
  filter:hue-rotate(180deg);
}
#img8
{ 
  filter:invert(100%);
}
#img9
{ 
  filter:opacity(40%);
}
#img10
{ 
  filter:drop-shadow(8px 8px 10px black);
}
</style>
</head>
<body>
	<div id="div_img">
	<p>The filter property : blur</p>
	<img id="img1" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : brightness</p>
	<img id="img2" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : contrast </p>
	<img id="img3" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : grayscale </p>
	<img id="img4" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : sepia </p>
	<img id="img5" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : saturate</p>
	<img id="img6" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : hue-rotate</p>
	<img id="img7" src="color.jpg" width="300" height="300"><br>
	<p>The filter property :invert </p>
	<img id="img8" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : opacity</p>
	<img id="img9" src="color.jpg" width="300" height="300"><br>
	<p>The filter property : drop-shadow</p>
	<img id="img10" src="color.jpg" width="300" height="300"><br><br><br>
</div>
</body>
</html>

backdrop-filter Property

  • This property is used to apply a filter effect to the area behind an element.
  • It allows you to create various visual effects, such as blurring or applying color adjustments to the background of an element, while keeping the content inside the element itself unaffected. Values for this property include:
    • blur(): Applies a blur effect to the background.
    • brightness(): Adjusts the brightness of the background.
    • contrast(): Adjusts the contrast of the background.
    • grayscale(): Converts the background to grayscale.
    • sepia(): Applies a sepia tone effect to the background.
    • saturate(): Adjusts the saturation of the background.
  • All the values of properties are same as given in previous property explanation.

Example

<!DOCTYPE html>
<html>
	<head>
		<style>
			body 
			{
				background-image: url('color.jpg'); 
				background-size:cover;
				background-position:center;
				height:600px;
				display:flex;
				justify-content: center;
				align-items: center;
			}
			.container 
			{
				padding: 20px;
				border-radius: 10px;
				/* Apply a blur effect to the background */
				backdrop-filter: blur(10px); 
			}
			.content 
			{
				text-align: center;
			}
			h1 
			{
				font-size: 24px;
				margin: 0;
			}
			p 
			{
				font-size: 16px;
				margin: 0;
			}
		</style>
	</head>
	<body>
		<div class="container">
			<div class="content">
				<h1>Blurred Background</h1>
				<p>This is some content inside the element.</p>
			</div>
		</div>
	</body>
</html>

object-fit Property

  • It is used to control how an HTML element that displays an image or video (such as an <img> or <video> element) should behave in terms of its size and positioning within its container.
  • It allows you to specify how the content should fit within the element’s dimensions. The values of this property are :
    • fill: This is the default value. It scales the content to completely fill the container, possibly distorting the aspect ratio of the content to make it fit.
    • contain: Scales the content proportionally to fit entirely within the container without cropping or distorting. The content may have empty space inside the container if it doesn’t have the same aspect ratio as the container.
    • cover: Scales the content proportionally to cover the entire container. This may result in cropping of the content if it doesn’t have the same aspect ratio as the container.
    • none: The content is not resized or scaled. It retains its original size and may overflow the container if it’s larger.
    • scale-down: Scales the content proportionally to fit within the container, but it won’t enlarge the content if it’s smaller than the container. It behaves like contain unless the content is smaller than the container, in which case it behaves like none.

Example

<!DOCTYPE html>
<html>
	<head>
		<style>
			.container1
			{
				width: 300px;
				height: 200px;
				border: 1px solid;
			}
			#im1 
			{
				width: 100%;
				height: 100%;
				object-fit: cover;
			}
			.container2
			{
				width: 300px;
				height: 200px;
				border: 1px solid;
			}
			#im2 
			{
				width: 100%;
				height: 100%;
				object-fit:fill;
			}
			.container3
			{
				width: 300px;
				height: 200px;
				border: 1px solid;
			}
			#im3 
			{
				width: 100%;
				height: 100%;
				object-fit: contain;
			}
			.container4
			{
				width: 300px;
				height: 200px;
				border: 1px solid;
			}
			#im4
			{
				width: 100%;
				height: 100%;
				object-fit:none;
			}	
			.container5
			{
				width: 300px;
				height: 200px;
				border: 1px solid;
			}
			#im5
			{
				width: 100%;
				height: 100%;
				object-fit:scale-down;
			}	
		</style>
	</head>
	<body>
		<div class="container1">
			<img id='im1' src="color.jpg">
		</div><br>
		<div class="container2">
			<img id='im2' src="color.jpg">
		</div><br>
		<div class="container3">
			<img id='im3' src="color.jpg">
		</div><br>
		<div class="container4">
			<img id='im4' src="color.jpg">
		</div><br>
		<div class="container5">
			<img id='im5' src="color.jpg">
		</div>
	</body>
</html>
Scroll to top