【问题标题】:CSS & React / Transition to change background color and font color isn't workingCSS & React / Transition 改变背景颜色和字体颜色不起作用
【发布时间】:2019-10-06 04:53:00
【问题描述】:

我正在尝试对悬停产生影响,以更改反应应用程序中的背景颜色和字体颜色。

这是我拥有的反应组件:

import * as React from 'react'
import styles from './Project.module.scss'

let Project = function(props){
    return (
        <div className={styles.Project}>
            <h1>{props.Title}</h1>
            <h4>{props.Budget? props.Budget: 'No budget specificed'}</h4>
        </div>
    )
}

export default Project

这是我的 Project.module.scss 代码:

.Project{
    width: 45%; 
    box-shadow: 1px 1px grey;
    border: 2px solid grey; 
    padding-left: 10px;
    box-sizing: border-box;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    color: blue;
    background-color: white;
    transition: all 2 ease;
    transition-property: background-color, color;
    -webkit-transition: all 2 ease;
    -webkit-transition-property:  background-color, color;

    &:hover{
        background-color: black;
        color: white;
    }
}

除了背景颜色和颜色的过渡之外,所有属性似乎都有效。

感谢任何帮助。

【问题讨论】:

  • -webkit-transition: all 2s ease;2s
  • 你能把它作为答案发布吗?它奏效了。
  • 作为答案添加

标签: css reactjs sass css-transitions


【解决方案1】:
-webkit-transition: all 2s ease;

您需要在转换时间中添加s。它代表seconds

【讨论】:

    猜你喜欢
    • 2021-05-17
    • 2014-04-09
    • 2016-06-11
    • 2013-06-03
    • 2020-12-13
    • 1970-01-01
    • 1970-01-01
    • 2020-01-15
    • 1970-01-01
    相关资源
    最近更新 更多