相关疑难解决方法(0)

目标子元素样式组件

我试图通过将其作为孩子的目标来改变元素的nth-child(2)背景颜色,但我似乎无法让它工作,我尝试了不同元素的多种变化,似乎没有任何工作ColorBoxImgGrid

如果我不尝试定位nth-child元素,这将改变背景颜色

const ImgGrid = styled.div`
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  ${ColorBox} {
    background: #ff00ff;
  }
`
Run Code Online (Sandbox Code Playgroud)

我怎样才能针对nth-child(2)中的 ColorBox元素?

import React from 'react'
import styled from 'styled-components'
// import Img from '../../atoms/Img'
import { array, bool } from 'prop-types'

const Wrap = styled.div`
  padding: 20px 0;
`

const BoxWrap = styled.div`
  position: relative;
  border: 1px solid #000;
  height: auto;
  padding: 20px;
`

const Title = styled.div`
  position: absolute;
  display: flex; …
Run Code Online (Sandbox Code Playgroud)

reactjs styled-components

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

reactjs ×1

styled-components ×1