【问题标题】:Styled components: select div within div within current element样式化组件:在当前元素内的 div 内选择 div
【发布时间】:2021-01-30 20:49:51
【问题描述】:

我有一个样式化的组件模态,它有几个 div 作为子元素。我需要在第二级设置 div 的样式。

<StyledComponentModal>
 <div>
  <div> // <-- This one needs styling
    // ...
  </div>
 </div>
</StyledComponentModal

如何选择div

我尝试使用div div

const Modal = styled(MyModal)`
  background: transparent;
  height: auto;
  margin: ${rem(0)} auto;
  margin-top: 25vh;
  width: 90vw;

  div div {
    /* doesn't work :( */
  }
`;

我还尝试了其他东西,例如 &amp;div div 等,但无法正常工作。

如何选择和设置该 div 的样式?

【问题讨论】:

    标签: css css-selectors styled-components


    【解决方案1】:

    我想通了:

    > div > div {
    
    }
    
    

    有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-30
      • 1970-01-01
      • 2012-03-19
      • 1970-01-01
      相关资源
      最近更新 更多