4.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <!-- 将jsx转为js -->
  8. <script src="./babel.min.js"></script>
  9. <!-- react核心库 -->
  10. <script src="./react.development.js"></script>
  11. <!-- react中dom操作库 -->
  12. <script src="./react-dom.development.js"></script>
  13. <style>
  14. /* .box {
  15. width: 500px;
  16. height: 500px;
  17. border: 1px solid #000;
  18. margin: 0 auto;
  19. } */
  20. </style>
  21. </head>
  22. <body>
  23. <div id="root"></div>
  24. <script type="text/babel">
  25. let newBox = {
  26. width: '500px',
  27. height: '500px',
  28. border: '1px solid #f00',
  29. margin: '0 auto',
  30. display: 'flex',
  31. justifyContent: 'space-between',
  32. alignItem: 'center'
  33. }
  34. let left = {
  35. width: '200px',
  36. height: '200px',
  37. backgroundColor: 'purple',
  38. color: "#fff"
  39. }
  40. let box = (
  41. <div style={newBox}>
  42. <div style={left}>左侧盒子</div>
  43. <div style={{
  44. width:'200px',
  45. height:'200px',
  46. backgroundColor:'#ff0',
  47. color:'#f00'
  48. }}>右侧盒子</div>
  49. </div>
  50. )
  51. let showPage = document.querySelector("#root");
  52. ReactDOM.createRoot(showPage).render(box);
  53. </script>
  54. </body>
  55. </html>