搜索

首页  >  问答  >  正文

使用 Psuedo 元素的 CSS 悬停效果与主元素重叠

基本上,当我悬停时,我希望效果如下所示:

我的网站在这里

代码如下忽略!重要

.cta-button-menu, .cta-button-menu::before {
        transition:all 0.3s linear !important;
        width: 120px !important;
        height: 50px !important;
        display: inline-flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    .cta-button-menu:hover {
        transform:rotateZ(-45deg) !important;
        background: #21B6CD !important;
        color: white !important;
    }   
    .cta-button-menu::before {
        content:"Book Now" !important;
        background-color:transparent !important;
        position:absolute !important;
        @include main-font($white, 16px !important, $font-bold !important);
      }
    .cta-button-menu:hover::before{
        transform: rotateZ(90deg) !important;
        background-color:#e72f54 !important;
        border:none !important;
    }

出于某种原因,我无法让蓝色按钮与红色按钮重叠。想不通

P粉838563523P粉838563523240 天前285

全部回复(1)我来回复

  • P粉021708275

    P粉0217082752024-03-21 09:15:11

    交换 .cta-button-menu:hover set background: #e72f54.cta-button-menu:hover::before set background-color:#21B6CD 中的颜色。并且还要改变度数。希望这对你有用

    ul {
    margin-top: 60px;
    }
    .cta-button-menu,
        .cta-button-menu::before {
          transition: all 0.3s linear !important;
          width: 120px !important;
          height: 50px !important;
          display: inline-flex !important;
          justify-content: center !important;
          align-items: center !important;
        }
    
        .cta-button-menu:hover {
          transform: rotateZ(45deg) !important;
          background: #e72f54 !important;
          color: white !important;
    
        }
    
        .cta-button-menu::before {
          content: "Book Now" !important;
          background-color: transparent !important;
          position: absolute !important;
          @include main-font($white, 16px !important, $font-bold !important);
        }
    
        .cta-button-menu:hover::before {
          transform: rotateZ(-90deg) !important;
          background-color: #21B6CD !important;
          border: none !important;
    
        }

    回复
    0
  • 取消回复