“Użyj stylu w React” Kod odpowiedzi

JSX w stylu wbudowanym

//Multiple inline styles
<div style={{padding:'0px 10px', position: 'fixed'}}>Content</div>
Puzzled Puffin

reakcja w stylu wbudowanym

// You are actuallty better off using style props
// But you can do it, you have to double brace
// and camel-case the css properties
render() {
	return (
    	<div style={{paddingTop: '2em'}}>
      		<p>Eh up, me duck!</p>
      	</div>
    )
}
Kaotik

Użyj stylu w React

// use inline style in react
const myFunction = () => {
	return (
     <p style={{ fontSize: 24, margin: '0 auto', textAlign: 'center'}}>
       Hello world
    </p>
    );
}
Chetan Nada

Używanie stylizacji inline w React

function MyComponent(){
2
3return <div style={{ color: 'blue', lineHeight : 10, padding: 20 }}> Inline Styled Component</div>
4
5}
designerAlabi

Stylizacja reagują za pomocą CSS

//Use backgroundColor instead of background-color:
const Header = () => {
  return (
    <>
      <h1 style={{backgroundColor: "lightblue"}}>Hello Style!</h1>
      <p>Add a little style!</p>
    </>
  );
}
naly moslih

reakcja w stylu wbudowanym

// Typical component with state-classes
<ul className="todo-list">
  {this.state.items.map((item,i)=>({
<li 
 className={classnames({ 'todo-list__item': true, 'is-complete': item.complete })}>
            {item.name}
</li>
 })}
</ul>

// Using inline-styles for state
<li className='todo-list__item'
 style={(item.complete) ? styles.complete : {}} />
Clean Cheetah

Odpowiedzi podobne do “Użyj stylu w React”

Pytania podobne do “Użyj stylu w React”

Więcej pokrewnych odpowiedzi na “Użyj stylu w React” w JavaScript

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

Przeglądaj inne języki kodu