2前端案例-选项卡样式

 



<style>
.xuan {
margin: 20px 0px 0px 20px;
padding: 1px;
font-family: "Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,tahoma,arial,"WenQuanYi Micro Hei",Verdana,sans-serif,"\5B8B\4F53";
border-bottom:1px solid #999;
height: 25px;
line-height: 25px;
}
.xuan div{
display: inline-block;
}

.xuan li{
border:1px solid #999;
border-radius: 5px 5px 0px 0px ;
display: inline-block;
width: 100px;
color: #666;
text-align: center;
background: #eee;
}

.active1{
border-bottom:1px solid #fff !important;
background: #fff !important;
}
</style>
<div class="xuan" style="width:1650px ">
<div style="width:12%"><span style="font-size: 16px;color: #444;">商品管理</span>&nbsp;&nbsp;&nbsp;<span style="font-size: 12px;color: #888;">商品基本信息设置</span>&nbsp;&nbsp;</div>
<div style="width: 40%"><ul>
<a href=""><li class="active1">商品信息</li></a>
<a href=""><li>商品相册</li></a>
<a href=""><li>商品模型</li></a>
<a href=""><li>商品物流</li></a>
</ul></div>
<div style="width:45%"></div>
</div>
=============================

js代码
<script type="text/javascript" src="_ADMIN_/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    //委托事件,这个意思是这个对象下面的某个a后代点击时,执行事件
    $(".shij").on('click','li',function () {
        //遍历事件,意思所有的a遍历执行方法 所有的a的class为空
        $(".shij li").each(function () {
            $(this).attr("class", "");
        });
        //点击 这一个后代a加class 切2是active
        $(this).attr("class", "active1");

        //给ifranme赋值
        var hrefUrl=$('.active1').attr('hrefUrl');
        $('#iframe1').attr('src',hrefUrl);

        return false;
    })
</script>

html部分

 

 


<style>
   .xuan {
      background: #F5F5F5;
      margin: 0px;
      padding:5px 0px 1px 20px;
      font-family: "Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,tahoma,arial,"WenQuanYi Micro Hei",Verdana,sans-serif,"\5B8B\4F53";
      border-bottom:1px solid #ddd;
      height: 33px;
      line-height: 33px;
   }
   .xuan div{
      display: inline-block;
   }

   .xuan li{
      border:1px solid #bbb;
      border-radius: 5px 5px 0px 0px ;
      display: inline-block;
      width: 100px;
      color: #666;
      text-align: center;
        background: #eee;
   }

   .active1{
      border-bottom:1px solid #fff !important;
      background: #fff !important;
   }
</style>

<div class="xuan" style="width:1650px ">

   <div style="width:12%;"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span><span >商品管理</span> <span class="c-gray en">&gt;</span> 商品添加&nbsp;&nbsp;</div>
   <div style="width: 40%;margin-left: 250px;" class="shij"><ul>
      <a href=""><li class="active1" hrefUrl="{:url('Goods/goodsinfo')}">商品信息</li></a>
      <a href=""><li hrefUrl="{:url('Goods/goodImgs')}">商品相册</li></a>
      <a href=""><li hrefUrl="{:url('Goods/goodModel')}">商品模型</li></a>
      <a href=""><li hrefUrl="{:url('Goods/goodArea')}">商品物流</li></a>
   </ul></div>
   <div style="width:45%"></div>
</div>


<div id="iframe_box" class="Hui-article" style="margin-top: 10px;">
   <div class="show_iframe">
      <div style="display:none" class="loading"></div>
      <iframe id="iframe1" scrolling="yes" frameborder="0" src="{:url('Goods/goodsinfo')}"></iframe>
   </div>
</div>
</body>

转载于:https://www.cnblogs.com/wujunbin/p/7461044.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
前端实现选项卡切换内容,可以使用HTML、CSS和JavaScript来实现。以下是一个简单的示例: HTML代码: ```html <div class="tab"> <button class="tablinks" onclick="openTab(event, 'tab1')">选项卡1</button> <button class="tablinks" onclick="openTab(event, 'tab2')">选项卡2</button> <button class="tablinks" onclick="openTab(event, 'tab3')">选项卡3</button> </div> <div id="tab1" class="tabcontent"> <h3>选项卡1</h3> <p>这是选项卡1的内容。</p> </div> <div id="tab2" class="tabcontent"> <h3>选项卡2</h3> <p>这是选项卡2的内容。</p> </div> <div id="tab3" class="tabcontent"> <h3>选项卡3</h3> <p>这是选项卡3的内容。</p> </div> ``` CSS代码: ```css .tab { overflow: hidden; border: 1px solid #ccc; background-color: #f1f1f1; } .tab button { background-color: inherit; float: left; border: none; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; } .tab button:hover { background-color: #ddd; } .tab button.active { background-color: #ccc; } .tabcontent { display: none; padding: 6px 12px; border: 1px solid #ccc; border-top: none; } ``` JavaScript代码: ```javascript function openTab(evt, tabName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(tabName).style.display = "block"; evt.currentTarget.className += " active"; } ``` 这个示例中,我们使用了HTML的`button`元素来作为选项卡的标签,使用`div`元素来作为选项卡的内容。CSS用于定义选项卡样式JavaScript用于实现选项卡的切换功能。 在JavaScript代码中,`openTab`函数接受两个参数,第一个参数是事件对象,第二个参数是要显示的选项卡的ID。函数首先隐藏所有选项卡的内容(通过将它们的`display`属性设置为`none`),然后将指定选项卡的内容显示出来(通过将其`display`属性设置为`block`),最后将当前选项卡的按钮标签的`active`类设置为激活状态。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值