<div id="app" class="container"></div>
@import 'https://fonts.googleapis.com/css?family=Share+Tech+Mono';
@import 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css';
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/1376484/jess-harding-lqT6NAmTaiY-unsplash.jpg'),radial-gradient(#28a3dd, #0d7751);
background-size: cover;
background-position: center;
font-family: "Share Tech Mono", monospace;
font-size: 2rem;
background-blend-mode: multiply,screen, overlay;
}
.container {
position: relative;
background-size: cover;
background-position: center;
backdrop-filter: blur(20px);
background-color: rgba(255, 255, 255, 0.5);
border-radius: 5px;
padding:2vw;
box-sizing: border-box;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: .3s ease;
margin: 3vw;
div {
display: flex;
justify-content: center;
align-items: center;
}
}
.grandpa {
width: 80vh;
height: 80vh;
border-radius: 100%;
background: #f36;
}
.parent {
width: 60vh;
height: 60vh;
border: 5px solid #f90;
border-radius: 100%;
background: #07f;
}
.children {
width: 30vh;
height: 30vh;
border-radius: 100%;
background: #000;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
white-space: nowrap;
}
View Compiled
class App extends React.Component {
constructor(props) {
super(props)
this.state={
x: 0,
y: 0
}
this.grandpaFn = this.grandpaFn.bind(this)
this.parentFn = this.parentFn.bind(this)
this.childrenFn = this.childrenFn.bind(this)
}
grandpaFn(e) {
console.log('Grandpa Element')
}
parentFn(e) {
console.log('Parent Element')
}
childrenFn(e){
console.log('Children Element')
const {clientX, clientY} = e
setTimeout(()=>{
this.setState({
x: clientX,
y: clientY
})
console.log(`1s之后获得鼠标点击时坐标值:(${this.state.x}, ${this.state.y})`)
},1000)
}
render() {
return (
<div className="grandpa" onClick={this.grandpaFn}>
<div className="parent" onClick={this.parentFn}>
<div className="children" onClick={this.childrenFn}>({this.state.x}, {this.state.y})</div>
</div>
</div>
)
}
}
const rootElement = document.getElementById("app");
ReactDOM.render(<App />, rootElement);
View Compiled
This Pen doesn't use any external CSS resources.