微信订阅号:Rabbit_svip
效果图
微信订阅号: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=""></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=""></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=""></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=""></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=""></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文件。
作者:Rabbit_svip
链接:https://www.jianshu.com/p/06bbc16b7038
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦