overflow之锚点技术实现选项卡

本文介绍如何使用简单的锚点技术实现页面上的选项卡及轮播效果,仅需少量CSS和HTML代码即可完成,适用于单屏页面设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我们知道通过锚点技术可以实现页面内容的定位,如果我们把这些内容放置在一个容器中,看看我们能做什么。

     

艾玛,选项卡、轮播,有木有,瞬间有种蛋碎的赶脚,以前写个选项卡,破轮播,费了多大的劲儿呀,现在,你只需几行代码甚至是不写js就能实现该功能,sorry,有点自我陶醉了,表废话啦,请上车,现在就带你飞.

html

<div class="box">
        <div class="list" id="one">1</div>
        <div class="list" id="two">2</div>
        <div class="list" id="three">3</div>
        <div class="list" id="four">4</div>
</div>
<div class="link" style="margin-bottom:150px;">
        <a href="#one" class="click">1</a>
        <a href="#two" class="click">2</a>
        <a href="#three" class="click">3</a>
        <a href="#four" class="click">4</a>
</div>

css

.box{
        width:300px;
        height:200px;
        overflow:hidden;
        /*other style*/
}
.box .list{
        width:100%;
        height:100%;
        /*other style*/        
}
#one{background:#ccc;}
#two{background:red;}
#three{background:blue;}
#four{background:green;}

 

注意:适用场景,页面为单屏页面,否会影响html的滚动条

 

转载于:https://www.cnblogs.com/xfz1987/p/5650300.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值