纯css实现边框动画特效 css

在这里插入图片描述
下面是完整代码,实现图示效果,效果为出现四个白框,和去除黑色背景。

<!-- 了解更多模块 -->
<!DOCTYPE html>
<html>
	<head>
		<style type="text/css">
		body{
			background-color: #D0D0D0;
		}
.knowmorbutton
{
	width: 100px;
	height: 40px;
	position: relative;
	
	background-color: #000000;
	box-shadow:0px 0px  60px 0.5px #d0d0d0;
}
.knowmorbutton:hover
{
	cursor:pointer;
	background:transparent;
}
.know-top
{
	position: absolute;
	right: 0px;
	top: 0px;
	width: 0px;
	height: 5px;
	background-color: #FFFFFF;
	transition: all 0.2s;
}
.know-left
{
	position: absolute;
	top: 0px;
	left: 0px;
	width: 5px;
	height: 0px;
	background-color: #FFFFFF;
}
.knowmorbutton:hover .know-left
{
	height: 35px;
	transition: all 0.2s;
	cursor:pointer;
}
.know-right
{
	position: absolute;
	bottom: 0px;
	right: 0px;
	width: 5px;
	height: 0px;
	background-color: #FFFFFF;
}
.knowmorbutton:hover .know-right
{
	cursor:pointer;
	height: 35px;
	transition: all 0.2s;
}
.knowmorbutton:hover .know-left
{
	height: 35px;
	transition: all 0.2s;
}
.knowmorbutton:hover .know-top
{
	cursor:pointer;
	width: 100px;
}

.know-bottom
{	position: absolute;
	left: 0px;
	bottom: 0px;
	width: 0px;
	height: 5px;
	background-color: #FFFFFF;
	transition: all 0.2s;
}
.knowmorbutton:hover .know-bottom
{
	width: 100px;
}
.knowmore
{
	color: #FFFFFF;
	position: relative;
	text-align: center;
	top: 7px;
	
	
}
		</style>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
					
				</div>
				<!-- 了解更多模块 -->
				<div class="knowmorbutton">
					<div class="know-top">
						
					</div>
					<div class="know-left">
						
					</div>
					<div class="know-right">
						
					</div>
					<div class="know-bottom">
						
					</div>
		
				</div>
				
				
				</div>
				<!-- 了解更多模块 -->
			</div>
	</body>
</html>

					<!-- 了解更多模块 -->

        虽然代码看着很长其实原理很简单,使用子类选择器,在.knowmorbutton盒子悬停的同时,让四个盒子出来就行;
四个盒子分别使用绝对定位,定位到四个角,两个不给宽度,两个不给长度。
        然后在悬停父类knowbuttton,清除阴影我用的是backgroune:transparent;
        核心思想是悬停父类,触发子类效果。定位父相子绝,不影响布局。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

只会写bug的靓仔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值