Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

inline styling react

//double brackets, quotations around both key and value in css
<span style={{"font-weight": "750"}}>React Inline Styling </span>
Comment

use style in react

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

inline styling in react

render() {
    return (
         <p style={{color: 'red'}}>
            Example Text
        </p>
    );
}
Comment

using inline styling in React

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

jsx style styling

style={{color: "white",
        backgroundColor: '#f1356d',
        borderRadius: '8px'
       }}
Comment

jsx inline style

<div style={{ width: '200px', backgroundColor: 'red' }}>Something</div>
Comment

react div style

return <div style={{display: 'inline-block'}}>
Comment

Styling React Using CSS

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

inline styling in react

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

react style

marginHorizontal
alignContent
alignSelf
aspectRatio
borderBottomWidth
borderEndWidth
borderLeftWidth
borderRightWidth
borderStartWidth
borderTopWidth
borderWidth
bottom
display
end
flex
flexBasis
flexDirection
flexGrow
flexShrink
flexWrap
height
justifyContent
left
margin
marginBottom
marginEnd
alignItems
marginLeft
marginRight
marginStart
marginTop
marginVertical
maxHeight
maxWidth
minHeight
minWidth
overflow
padding
paddingBottom
paddingEnd
paddingHorizontal
paddingLeft
paddingRight
paddingStart
paddingTop
paddingVertical
position
right
start
top
width
zIndex
direction
Comment

inline styling react

// Change the background color to red
document.body.style.backgroundColor = "red"; 
Comment

css in reactjs

Assuming you have 2 separate files: Example.css and Example.js

Use the '.' to reference a className that you'll use later 

.primary{
	color: red;
}

<h1 className="primary"> Hello, World </h1>

In this case "primary" in the className is referencing .primary in the CSS file
Comment

PREVIOUS NEXT
Code Example
Javascript :: hashset in javascript 
Javascript :: clearing cookie in js 
Javascript :: regex not something 
Javascript :: add element into array 
Javascript :: javascript alert 
Javascript :: onfocus js 
Javascript :: change js 
Javascript :: metro server not running react native 
Javascript :: how to update node js through terminal 
Javascript :: Scroll elementleft using js 
Javascript :: catch javascript 
Javascript :: react router cannot read location of undefined 
Javascript :: javascript every 
Javascript :: remover ultimo character string javascript 
Javascript :: find max and min value in array javascript 
Javascript :: javascript factorial recursion 
Javascript :: jsdoc for express routes 
Javascript :: create new angular project specific version 
Javascript :: sequelize mariadb example 
Javascript :: typeof array 
Javascript :: how to add to an array js 
Javascript :: json in listview flutter 
Javascript :: js for in 
Javascript :: javascript for loop array backwards 
Javascript :: javascript array filter duplicates in react 
Javascript :: accept 2 values after decimal in angular forms 
Javascript :: jest run specific test 
Javascript :: setAttribute is not a function jquery 
Javascript :: how to get in an object js 
Javascript :: queryselectorall example 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =