【CSS3】页面平滑过渡

7275569-83c2c4056c87f7a7.jpg
微信订阅号:Rabbit_svip

效果图


7275569-785b07b4a5afc6f1.gif
微信订阅号:Rabbit_svip

在线预览:https://quick-z.github.io/CSS3-smooth-transition/

HTML代码
<div class="container">
        <div class="st-container">
            <!-- nav begin -->
            <input type="radio" name="radio-set" id="st-control-1" checked="checked">
            <a href="#st-panel-1">Serendipity</a>
            <input type="radio" name="radio-set" id="st-control-2">
            <a href="#st-panel-2">Happiness</a>
            <input type="radio" name="radio-set" id="st-control-3">
            <a href="#st-panel-3">Tranquillity</a>
            <input type="radio" name="radio-set" id="st-control-4">
            <a href="#st-panel-4">Positivity</a>
            <input type="radio" name="radio-set" id="st-control-5">
            <a href="#st-panel-5">Passion</a>
            <!-- nav end  content begin-->
            <div class="st-scroll">
                <section class="st-panel" id="st-panel-1">
                    <div class="st-deco" data-icon="&#xe601;"></div>
                    <h2>Serendipity</h2>
                    <p>Banksy adipisicing eiusmod banh mi sed. Squid stumptown est odd future nisi, commodo mlkshk pop-up adipisicing retro.</p>
                </section>
                <section class="st-panel st-color" id="st-panel-2">
                    <div class="st-deco" data-icon="&#xe602;"></div>
                    <h2>Happiness</h2>
                    <p>Art party readymade beard labore cosby sweater culpa. Art party whatever incididunt, scenester umami polaroid tofu.</p>
                </section>
                <section class="st-panel" id="st-panel-3">
                    <div class="st-deco" data-icon="&#xe605;"></div>
                    <h2>Tranquillity</h2>
                    <p>Sint aute occaecat id vice. Post-ironic fap pork belly next level godard, id fanny pack williamsburg forage truffaut.</p>
                </section>
                <section class="st-panel st-color" id="st-panel-4">
                    <div class="st-deco" data-icon="&#xe607;"></div>
                    <h2>Positivity</h2>
                    <p>Mixtape fap leggings art party, butcher authentic farm-to-table you probably haven't heard of them do labore cosby sweater.</p>
                </section>
                <section class="st-panel" id="st-panel-5">
                    <div class="st-deco" data-icon="&#xe615;"></div>
                    <h2>Passion</h2>
                    <p>Fixie ad odd future polaroid dreamcatcher, nesciunt carles bicycle rights accusamus mcsweeney's mumblecore nulla irony.</p>
                </section>
            </div>
        </div>
    </div>

代码有点长,可以点击阅读原文下载源码看。

原理是通过单选按钮(radio)来控制选中了哪个标签。

通过radio来控制选中的样式。而这里把radio标签隐藏了,所以表面看不出有radio标签。

然后通过<a>标签控制跳转到哪个id,也就是跳转到哪个锚点。

最后通过transition这个属性来控制过渡效果。详情可以看CSS文件。

这里引用了iconfont做图标字体。

代码下载

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值