Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

css - React Passing style background color from parent to child

I have a problem with scss, I would like the color to be passed from parent (element_parent) to child (element_child) for even / odd parent numbers.

react code fragment:

<div>
  {props.data && props.data.map(item => (
    <div className="element_parent">
    <ListElement
      key={Math.floor(Math.random() * (100000000000 - 0)) + 0}
      text={item.name}
      />
      {item.value && <Tree data={item.value} generalVisible={item.generalVisible} visible={item.visible}/>}
    </div>
  ))}
</div>

scss fragment code:

.element_parent:nth-child(even) .element_child {
    background: #ccd9ff;
}

.element_parent:nth-child(odd) .element_child {
    background: #ffffff;
}

In the ListElement component the element_child class is assigned.

question from:https://stackoverflow.com/questions/65933890/react-passing-style-background-color-from-parent-to-child

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...