用CSS3怎样做底部按钮滑入滑出的效果
Admin 2022-05-21 群英技术资讯 1783 次浏览
在这篇文章中,我们来学习一下“用CSS3怎样做底部按钮滑入滑出的效果”的相关知识,下文有详细的讲解,易于大家学习和理解,有需要的朋友可以借鉴参考,下面就请大家跟着小编的思路一起来学习一下吧。1,首先需要用的是 CSS3的 target 选择器,配合a标签指定id选择器切换目标元素,用于选取当前活动的目标元素。
2,CSS3 的 transition 动画,这里不做详细介绍
看一下效果图:
点击滑出按钮,元素从底部匀速滑入到页面一定高度;再点击滑入,元素从当前位置匀速滑入期初位置。

直接上代码:
<h1>CSS3滑入/滑出效果</h1>
<div id="volet_clos">
<div id="volet">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima quisquam tempora quaerat dolores molestias reiciendis .</p>
<p>vero labore voluptates necessitatibus ut? Et</p>
<p>vero labore voluptates necessitatibus ut? Et</p>
<p>vero labore voluptates necessitatibus ut? Et</p>
<p>vero labore voluptates necessitatibus ut? Et</p>
<a href="#volet" aria-hidden="true" class="ouvrir">滑出</a>
<a href="#volet_clos" aria-hidden="true" class="fermer">滑入</a>
</div>
</div>
<style>
#volet_clos {position: fixed;top: 0px; left: 0;width: 100%;}
#volet {width: 250px;padding: 10px;background: #6B9A49; color: #fff;width: 100%;}
/* 初始定位 */
#volet {position: absolute;left: 0px;top: 375px;transition: all .5s ease-in;}
#volet a.ouvrir,#volet a.fermer {position: absolute;right: -88px;top: 150px;}
/* 点击过后改变 target */
#volet a.fermer {display: none;}
#volet:target {left: 0px;top: 150px;}
#volet:target a.fermer {display: block;}
#volet:target a.ouvrir {display: none;}
#volet_clos:target #volet {left: 0px;top: 375px;}
#volet a.ouvrir,#volet a.fermer{position: absolute;right: calc(40%);top: -40px;padding: 10px 25px; background: #555; color: #fff; text-decoration: none;text-align: center; width: 120px;}
</style>
案例二,tab标签页切换效果

<h1>tab标签页切换效果</h1>
<div class="swiper-box">
<div class="swiper-cont">
<div class="swiper1" id="swiper1"></div>
<div class="swiper2" id="swiper2"></div>
<div class="swiper3" id="swiper3"></div>
</div>
<div class="swiper-num">
<a href="#swiper1">1</a>
<a href="#swiper2">2</a>
<a href="#swiper3">3</a>
</div>
</div>
/* tab标签页切换效果 css */
.swiper-box{position: relative;width: 500px; height: 300px; margin: 20px auto; background: #f1f1f1;}
.swiper-cont div,.swiper1,.swiper2,.swiper3{ width: 0%; height: 300px;position: absolute;top: 0; left: 0;transition: width .5s linear;}
.swiper1{background: linear-gradient(to top, #fba555, #ffed6c 75%);}
.swiper2{background: linear-gradient(to left, #55d5fb, #fd74a7 75%);}
.swiper3{background: linear-gradient(to top left, #55fb69, #6cfff1 75%);}
.swiper-num{position: absolute; bottom: 0;right: 0;display: inline-block;z-index: 9;}
.swiper-num a{display: inline-block;margin-left: 10px;padding: 10px 20px; color: #333;font-size: 14px; text-decoration: none;font-weight: bold;background: rgba(255,255,255,.45);}
.swiper-num a:hover,.swiper-num a:active{ color: red;cursor: pointer;background: rgba(255,255,255,.95);}
.swiper-box :target{width: 100%;transition: width .5s linear;}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了浅谈CSS3 box-sizing 属性 有趣的盒模型 ,需要的朋友可以参考下
在用了Flex布局会发现,当水平排列后,会发现所有子项的高度都变成一样的了。这是因为Flex 布局会默认:把所有子项变成水平排列。默认不自动换行。让子项与其内容等宽,并把所有子项的高度变为最高子项的高度。这样设置背景色的时候非常不...
css中,可以利用overflow属性来实现字体溢出隐藏效果。下面通过代码示例来介绍一下overflow属性如何实现字体溢出隐藏<!DOCTYPE html><html><head><meta charset="utf-8"><sty
这篇文章主要介绍了HTML5 Blob 实现文件下载功能的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
实现的原来就是:在一个宽高为0像素的块状元素中设置border属性,例如.box{width:0px;height:0;border-bottom:50px#F00solid;border-left:50px#03Fsolid;border-right:50px#F90solid;border-top:50px#6C0solid;}在浏览器中的显示如图:这样就有上下左右四个三角形了,再把除了要用的三角外的其他3个三角(border)颜色设置 ...
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008