CSS3完成div从下往上滑入滑出实际效果示例

日期:2021-02-27 类型:科技新闻 

关键词:在线网页制作,建网页,个人简介网页制作,简单网页,建立网页

1,最先必须用的是 CSS3的 target 挑选器,相互配合a标识特定id挑选器切换总体目标元素,用于选择当今主题活动的总体目标元素。
2,CSS3 的 transition 动漫,这里不做详尽详细介绍

看1下实际效果图:

点一下滑出按钮,元素从底部匀速滑入到网页页面1定高宽比;再点一下滑入,元素从当今部位匀速滑入期初部位。


立即上编码:

<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: ⑻8px;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: ⑷0px;padding: 10px 25px; background: #555; color: #fff; text-decoration: none;text-align: center; width: 120px;}
    </style>

实例2,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;}

到此这篇有关CSS3完成div从下往上滑入滑出实际效果示例的文章内容就详细介绍到这了,更多有关CSS3完成div从下往上滑入滑出內容请检索脚本制作之家之前的文章内容或再次访问下面的有关文章内容,期待大伙儿之后多多适用脚本制作之家!