React.js css box-shadow not working

Viewed 60168

I am using react.js v15.6.1

I have a css file with a style like below:

.well {

    -webkit-box-shadow: 1px 3px 1px #9E9E9E;
    -moz-box-shadow: 1px 3px 1px #9E9E9E;
    box-shadow: 1px 3px 1px #9E9E9E;

}

I tried to use it inside react.js but not working like follows:

import React, { Component } from "react";
var Bootstrap = require('react-bootstrap')

export default class Title extends Component {

  render() {

    return (

      <div style={styles.well}>
              <div style={styles.header}>Business Background</div>
              <hr/>
              <p>
                  hello hello
             </p>    
      </div>


    );
  }
}

const styles = {

  well:{
    webkitBoxShadow: "1px 3px 1px #9E9E9E",
    mozBoxShadow: "1px 3px 1px #9E9E9E",
    boxShadow: "1px 3px 1px #9E9E9E"

  }

};

even I changed to just

  well:{
    boxShadow: "1px 3px 1px #9E9E9E"
  }

it doesn't work tooenter image description here

If you look at picture above, Hello 1 is from generated from react and Hello 2 is from css file

I do not want to use css-loader or styled-components library as I want to keep things simple for now.

2 Answers

Just implement the styles above return method.

import React, { Component } from "react";
var Bootstrap = require('react-bootstrap')

export default class Title extends Component {
    render() {
        var well={
            boxShadow: "1px 3px 1px #9E9E9E"
        }
        var header={
            color:"#000",
            fontWeight:"550"
        }

        return (
            <div style={well}>
                <div style={header}>Business Background</div>
                <hr/>
                <p>hello hello</p>
            </div>
        );
    }
}
Related