jquery+css三角形旋转

html

<div class="head-cont">
                        <div class="head-tit head-titA">切换数据库</div>
                        <div class="head-item">
                                <a class="_p">123</a>
                                <a class="_p">456</a>
                                <a class="_p">789</a>
                                <a class="_p">食品贵伐判定结束系统</a>
                        </div>
                    </div>

css

.head-tit{
        background: #2469b7;
        color: #fff;
        border-radius: 5px;
        padding: 5px 30px 5px 20px;
        line-height: 28px;
        position: relative;
        cursor: pointer;
    }
    .head-titA::after{
        content: '';
        position: absolute;
        display: block;
        width: 0;
        height: 0;
        bottom: 40%;
        right: 10px;
        border: solid transparent 0.6rem;
        border-bottom-color: #fff;
        -webkit-transform: rotate(180deg) translateY(-50%);
        transform: rotate(180deg) translateY(-50%);
        }
    .head-titB::before {
        content: '';
        position: absolute;
        display: block;
        width: 0;
        height: 0;
        bottom: 40%;
        right: 10px;
        border: solid transparent 0.6rem;
        border-bottom-color: #fff;
        }
      .head-item{
        background-color: #fff;
        border-radius: 5px;
        position: absolute;
        z-index: 999;
        box-shadow: 1px 1px 5px #dde4ec;
        display: none;
      }  
      .head-item ._p{
          line-height: 38px;
          padding: 0 12px;
          border-bottom: 1px solid #ececec;
          box-sizing: border-box;
          margin: 0;
          display: block;
      }
      .head-item ._p:last-child{
        border-bottom: none;
      }
      .head-item ._p:hover{
        color: #2469b7;
        cursor: pointer;
      }
      .head-item ._p:hover::before{
        content: '';
        position: absolute;
        height: 38px;
        display: block;
        border-left: 4px solid #2469b7;
        left:0
      }

jq

$(function(){
        $('.head-tit').on('click',function(event){
            $('.head-item').toggle();
            event.stopPropagation(); 
            if($(this).hasClass("head-titA")){
          $(this).removeClass("head-titA").addClass("head-titB");
         }else{
          $(this).removeClass("head-titB").addClass("head-titA");
         }
        })
        $(document).click(function(e){  
            $(".head-item").hide();
        });  

    })

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值