伪类hover 触碰特效

伪类hover特效作用在本体元素身上时候使用方式

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style>
			.file-btn {
				float: left;
				width: 100px;
				height: 50px;
				border: 2px solid blanchedalmond;
				background-color: antiquewhite;
				margin: 0;
				padding: 0;
				line-height: 50px;
				text-align: center;
				cursor: pointer;
			}

			.file-btn:hover {
				background-color: sandybrown;
				border: 2px solid sienna;
			}
		</style>
	</head>
	<body>
		<div class="file-btn">伪类hover

		</div>
	</body>
</html>

伪类hover特效作用在子元素身上时候使用方式

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style>

			.file-btn {
				float: left;
				width: 100px;
				height: 50px;
				border: 2px solid blanchedalmond;
				background-color: antiquewhite;
				margin: 0;
				padding: 0;
				line-height: 50px;
				text-align: center;
				cursor: pointer;
				position: relative;
			}

			.file-btn .file-btn-son {
				position: absolute;
				width: 100px;
				height: 50px;
				border: 2px solid sienna;
				background-color: sandybrown;
				margin: 0;
				padding: 0;
				line-height: 50px;
				text-align: center;
				cursor: pointer;
				display: none;
				top: 50px;
				left: -2px;
			}
			
			.file-btn:hover .file-btn-son{
				display: block;
			}
		</style>
	</head>
	<body>
		<div class="file-btn">伪类hover
			<div class="file-btn-son">
				我是子元素
			</div>
		</div>
	</body>
</html>
posted @ 2024-12-12 22:37  觉远  阅读(8)  评论(0)    收藏  举报