为什么我的CSS中的::before在React中不起作用?

eyh26e7m  于 2023-08-08  发布在  React
关注(0)|答案(1)|浏览(188)

下面是React JS文件:

import React from "react";
import "./body-section.css";
import background from "../etc/Image-robot.jpg";

const Body = () => {
    return (
        <div className="body">
            <div 
                className="bdy-socials-section">
                <img 
                src={background}
                id="bg-img">
                </img>
            </div>
        </div>
    )
}

export default Body;

字符串
CSS文件:

.bdy-socials-section > img {
    width: 55vw;
    height: 80vh;
    transform: SkewY(5deg);
    position: relative;
    left: 50px;
}

.bdy-socials-section > img::before {
    content: "";
    display: block;
}


不幸的是,我在Chrome浏览器中没有看到任何视觉变化
我其实是在一个死胡同:<

t3psigkw

t3psigkw1#

// Body.jsx
function App() {
  return (
    <div className="body">
      <div
        className="bdy-socials-section">
        <div className='img-container'>
          <img
            src='https://images.pexels.com/photos/12825195/pexels-photo-12825195.png?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1'
            id="bg-img"
          />
        </div>
      </div>
    </div>
  )
}

export default App

个字符

相关问题