css 左侧和右侧的Box-shadow不适用于ReactJs

lstz6jyr  于 2023-05-02  发布在  React
关注(0)|答案(2)|浏览(135)

我试图使用CSS在React Js中仅在部分的右侧和左侧应用薄阴影,但我只在一侧得到阴影。下面是代码

.MainSection{
    margin-top:2%;
    background-color: white;
    width: 40%;
    border: solid 1.5px gray;
    box-shadow: -60px 0px 100px -90px #000000,60px 0px 100px -90px #000000;
    
}
import React from "react";
import "./MainSection.css";

function MainSection() {
  return (
    <div className="MainSection">
      <h1>MainSection</h1>
    </div>
  );
}

export default MainSection;
ou6hu8tu

ou6hu8tu1#

您的box-shadow尺寸有问题。如果您更改尺寸,css的其余部分将正常工作

.MainSection{
    margin-top:2%;
    background-color: white;
    width: 40%;
    border: solid 1.5px gray;
    box-shadow: 22px 0 15px -4px #000000, -22px 0 8px -4px #000000;
}
<div class="MainSection">
  <h1>MainSection</h1>
</div>
1l5u6lss

1l5u6lss2#

使用此添加框阴影左右两侧

box-shadow: -60px 0px 100px -20px #000000, 60px 0px 100px -20px #000000;

相关问题