How to apply CSS and Styling to a React component

后端 未结 7 723
梦如初夏
梦如初夏 2020-12-08 06:19

I have been looking, however, I have had little luck finding any way to style the React.js file that I have created, I converted it from a standard web page, so I have the o

7条回答
  •  忘掉有多难
    2020-12-08 06:59

    As Vijay mentioned, React prefers inline styles.

    One common pattern is for each Component to have a single styles object that contains all the styles used in that Component, like so:

    var styles = {
      navBar: {
        backgroundColor: 'dark blue'
      },
      center: {
        textAlign: 'center'
      },
      rightNav: {
      },
      verticalLine: {
      },
    };
    
    var NavBar = React.createClass({
      render: function() {
        return (
          
    • daily specials
    • gift gallery
    • events
    •  search
     
    ); } });

提交回复
热议问题