用CSS3来完成风琴效果

css3如何制作风琴效果
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
开发工具与关键技术:Dw CSS3
作者:xqll
撰写时间:2019/01/19
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
来源于潘老师课程
-~----------------------------------------------------------------------
下面我来演示一下如果利用CSS3完成风琴效果
首先给它们一个div

<div class="fqdh">
	<a href=""><em>C</em>啦啦啦~</a>
	<a href=""><em>S</em>哈哈哈~</a>
	<a href=""><em>S</em>噜噜噜~</a>
	<a href=""><em>3</em>嗷嗷嗷~</a>
	<a href=""><em>风</em>哇哇哇~</a>
	<a href=""><em>琴</em>呵呵呵~</a>
	<a href=""><em>导</em>哦哦哦~</a>
	<a href=""><em>航</em>欧欧欧~</a>
</div>

用a标签包裹住里面的内容,em标签包裹住显眼的内容
然后给大的div设置一下宽高位置什么的

.fqdh{
	width: 150px;
	height: 250px;
	position: fixed;
	top: 200px;
	right: 0px;
}

然后就是给a标签设置内容

.fqdh a{
	display: block;
	width: 150px;
	height: 30px;
	margin-bottom: 2px;
	text-decoration: none;
	background: #f9f9f9;
	font-size: 13px;
	line-height: 30px;
}

设置一些宽高 字体大小颜色 和边距
接下来是给em标签设置

.fqdh a em{
	display: inline-block;
	width: 30px;
	height: 30px;
	background: rgba(99,134,231,1.00);
	font-size: 16px;
	color: red;
	text-align: center;
}

样式设置得差不多了 效果是这样的在这里插入图片描述
我要做的是把它除去em标签以为的隐藏起来、当鼠标移入的时候会有风琴效果
就像这样在这里插入图片描述
还有这样在这里插入图片描述
而操作起来也只是用到CSS3就可以实现
代码图如下

	transform: translateX(120px);
	transition: all 0.2s ease;

在a标签里面设置 往x轴里面移120个像素 、让它只裸露出em标签出来

.fqdh a em:hover{
	background: #ff6600;
}
.fqdh:hover a{
	transform: translateX(0px);
}

这个设置是 点击em标签的时候 背景颜色会变为#ff6600
鼠标点击a标签的时候 隐藏的a标签会裸露出来


.fqdh a:nth-of-type(1){
	transition-delay: 0.05s;
}
.fqdh a:nth-of-type(2){
	transition-delay: 0.1s;
}
.fqdh a:nth-of-type(3){
	transition-delay: 0.15s;
}
.fqdh a:nth-of-type(4){
	transition-delay: 0.2s;
}
.fqdh a:nth-of-type(5){
	transition-delay: 0.25s;
}
.fqdh a:nth-of-type(6){
	transition-delay: 0.3s;
}
.fqdh a:nth-of-type(7){
	transition-delay: 0.35s;
}
.fqdh a:nth-of-type(8){
	transition-delay: 0.4s;
}

上面是设置当鼠标点击a标签后 多长时间后实现代码
上一个a标签比下一个a标签要实现的时间短一点 然后鼠标移动到a标签后 显示出来的效果 会有很好的美观效果
用起来简单又方便

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值