首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我正在尝试将内部文本更改为白色悬停颜色

我正在尝试将内部文本更改为白色悬停颜色
EN

Stack Overflow用户
提问于 2019-08-04 18:26:32
回答 2查看 61关注 0票数 0

我有问题,使内部文本更改悬停颜色为白色。我正在使用::之前: hover..当我悬停的时候,整个div都可以改变,但是文本仍然是黑色的,为什么我的代码不能工作?

代码语言:javascript
复制
    .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;
      } 
    } 
代码语言:javascript
复制
     <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>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-08-04 18:49:48

代码语言:javascript
复制
.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;
  } 
代码语言:javascript
复制
 <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>

票数 2
EN

Stack Overflow用户

发布于 2019-08-04 21:35:16

嵌套(当你在其他花括号中有大括号的时候)不是css的一个特性,只是像sass和less这样的css预处理器的一个特性。因此,您需要像这样扩展嵌套:

代码语言:javascript
复制
.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 .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 .feature-rect:hover::before {
  opacity: 1;
}

.feature .feature-rect:hover{
  color:#fff;
} 
代码语言:javascript
复制
<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>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57345768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档