检查react项目中.Home_continer_left{ width: box1Width + "%"; height: "100vh"; background-color: "rgb(228,233,247)"; display: "inline-block"; -webkit-transition:width 0.5s; }
时间: 2023-07-19 18:28:57 浏览: 47
根据代码来看,有以下几个问题:
1. `box1Width` 变量没有定义或者没有赋值,导致这个 CSS 样式无法生效。你需要将 `box1Width` 赋值给一个数值或者百分比,或者通过 props 或 state 传递进来。
2. `height` 和 `background-color` 属性值使用了双引号,这会导致样式无效。CSS 属性值应该使用单引号或者不使用引号。
3. `display` 属性使用了双引号,这也会导致样式无效。正确的写法是 `display: inline-block;`。
4. `transition` 属性定义了动画过渡时间,但是没有定义过渡的属性。你需要指定 `transition` 属性要过渡的属性名。
针对以上问题,你可以这样修改代码:
```css
.Home_continer_left {
width: ${box1Width}%;
height: 100vh;
background-color: rgb(228, 233, 247);
display: inline-block;
transition: width 0.5s;
}
```
注意,这里使用了模板字符串(template literals)来获取 `box1Width` 变量的值。如果你使用的不是 ES6,可以使用字符串拼接的方式获取变量的值。例如:
```css
.Home_continer_left {
width: " + box1Width + "%";
height: 100vh;
background-color: rgb(228, 233, 247);
display: inline-block;
transition: width 0.5s;
}
```
希望这些修改能够帮到你。