How to create a thumbnail image CSS?


Following is the code to create a thumbnail image using CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
img {
   border: 3px solid rgb(208, 255, 0);
   border-radius: 4px;
   width: 150px;
   height: 150px;
}
img:hover {
   box-shadow: 2px 2px 4px 2px rgb(60, 255, 53);
}
</style>
</head>
<body>
<h1>Thumbnail Image Example</h1>
<a target="_blank" href="https://images.pexels.com/photos/34950/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
<img src="https://images.pexels.com/photos/34950/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"/></a>
<h1>Clicking on the above thumbnail will open image in new tab</h1>
</body>
</html>

Output

The above code will produce the following output −

Updated on: 06-Apr-2020

511 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements