html - 我正在尝试使内部文本在悬停颜色为白色时发生变化

标签 html css sass

我无法在悬停颜色为白色时更改内部文本。我正在使用::before: hover.. 当我悬停整个 div 时可以更改但文本仍然是黑色为什么我的代码不起作用?

    .feature {
    .feature-rect {
        position: relative;
        height: 180px;
        width: 270px;
        border-radius: 20px;
        background-color: $light-color;
        @include box-shadow($form-shadow);
        text-align: center;
        margin-bottom: 30px;
        padding: 20px;
        z-index: 1;
        display: block;
      }
      
      .feature-rect::before {
        position: absolute;
        content: "";
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: linear-gradient(180deg, #232153 0%, #6F2365 100%);
        z-index: -1;
        transition: opacity 0.5s linear;
        opacity: 0;
        border-radius: 20px;
        display: block;
        color: #fff;
        cursor: pointer;
        
      }
      .feature-rect:hover::before {
        opacity: 1;
      } 
      .feature-rect:hover{
        color:#fff;
      } 
    } 
     <div class="feature">
       <div class="feature-rect">
       <img src="{{ config('static.images') }}images/card_feature_icon_2.png">
       <div class="title-light-color-font-s mt-10">Lorem Ipsome</div>
       <div class="title-content-font-xs mt-10">Lorem Ipsome Lorem Ipsome Lorem Ipsome Lorem Ipsome</div>
       </div>
     </div>

最佳答案

.feature-rect {
    position: relative;
    height: 180px;
    width: 270px;
    border-radius: 20px;
    background-color: $light-color;
    @include box-shadow($form-shadow);
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    z-index: 1;
    display: block;
  }

  .feature-rect::before {
    position: absolute;
    content: "";
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(180deg, #232153 0%, #6F2365 100%);
    z-index: -1;
    transition: opacity 0.5s linear;
    opacity: 0;
    border-radius: 20px;
    display: block;
    color: #fff;
    cursor: pointer;

  }
  .feature-rect:hover::before {
    opacity: 1;
  } 
  .feature-rect:hover{
    color:#fff;
  } 
  
  
  
  .feature-rect:hover div{
   color:#fff !important;
  } 
 <div class="feature">
   <div class="feature-rect">
   <img src="{{ config('static.images') }}images/card_feature_icon_2.png">
   <div class="title-light-color-font-s mt-10">Lorem Ipsome</div>
   <div class="title-content-font-xs mt-10">Lorem Ipsome Lorem Ipsome Lorem Ipsome Lorem Ipsome</div>
   </div>
 </div>

关于html - 我正在尝试使内部文本在悬停颜色为白色时发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57345768/

相关文章:

css - 如何在 Eclipse 中集成 CSS 预处理?

php - 静态页面有效,但是当放入 PHP 时,CSS 无法正确呈现

javascript - 使用 HTML 和 CSS 绘制带有填充的圆弧

CSS 垂直对齐图像与文本不起作用 (Wordpress)

javascript - Kendo UI Editor - 获取当前字体样式

sass - 在 scss 中声明自定义选择器?

html - 如何使用 Sass 获取动态列表中的项目数?

jquery - 如何将自动完成部分添加到html输入字段

jquery - 使用搜索按钮制作响应式导航栏

html - 如何更改:before on hover state