“Reaguj styl warunkowy” Kod odpowiedzi

Reaguj styl warunkowy

class App extends Component {
  constructor() {
    super()
    this.state = { isRed: true }
  }

  render() {
    const isRed = this.state.isRed

    return <p style={{ color: isRed ? 'red' : 'blue' }}>Example Text</p>
  }
}
Grieving Gharial

React Stylizacja warunkowa

// If you need to conditionally apply inline styles (apply all or nothing) then this notation also works:

<div style={ someCondition ? { textAlign:'center', paddingTop: '50%'} : {}} >
  {content}
</div>

// Or to apply it to particular property

<div
    style={{ 
      display: isExpanded ? 'block' : 'none', 
      marginBottom: '1rem'
    }}
  >
  {content}
</div>
shahul

Warunkowy rekwizyt w stylu

style={{ textDecoration: todo.completed && "line-through" }}

style={{ textDecoration: todo.completed ? "line-through" : 'none' }}
Runtime Terror

Styl inline installu w React

style={ someCondition ? { textAlign:'center', paddingTop: '50%'} : {}}
ALEX HAKOBYAN

Reaguj styl warunkowy

<ImageBackground source={Images.bg} style={ (navHeight==0) ? styles.bg1 : styles.bg2}>
Grieving Gharial

Odpowiedzi podobne do “Reaguj styl warunkowy”

Pytania podobne do “Reaguj styl warunkowy”

Więcej pokrewnych odpowiedzi na “Reaguj styl warunkowy” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu