如何使用 CSS 创建缩略图?
cssweb developmentfront end technology更新于 2025/9/29 3:56:17
以下是使用 CSS 创建缩略图的代码 −
示例
<!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>
输出
上述代码将产生以下输出 −
![]()
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

