Js-task2.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. html,
  6. body {
  7. height: 100%;
  8. margin: 0;
  9. padding: 0;
  10. }
  11. .container {
  12. display: flex;
  13. height: 100%;
  14. }
  15. .left-panel {
  16. flex: 1;
  17. background-color: #f1f1f1;
  18. padding: 20px;
  19. }
  20. .right-panel {
  21. flex: 1;
  22. padding: 20px;
  23. }
  24. .button {
  25. display: block;
  26. margin-bottom: 20px;
  27. padding: 10px 20px;
  28. background-color: #3498db;
  29. color: #fff;
  30. border: none;
  31. cursor: pointer;
  32. transition: background-color 0.3s ease;
  33. }
  34. .button:hover {
  35. background-color: #2980b9;
  36. }
  37. #info {
  38. font-size: 16px;
  39. margin-bottom: 20px;
  40. }
  41. .interactive-button {
  42. display: inline-block;
  43. padding: 5px 10px;
  44. background-color: #3498db;
  45. color: #fff;
  46. border: none;
  47. cursor: pointer;
  48. transition: background-color 0.3s ease;
  49. }
  50. .interactive-button:hover {
  51. background-color: #2980b9;
  52. }
  53. input[type="text"] {
  54. padding: 10px;
  55. width: 200px;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <div class="container">
  61. <div class="left-panel">
  62. <button class="button" onclick="showInfo('按钮1被点击')">按钮1</button>
  63. <button class="button" onclick="showInfo('按钮2被点击')">按钮2</button>
  64. <button class="button" onclick="showInfo('按钮3被点击')">按钮3</button>
  65. <button class="button" onclick="showInfo('按钮4被点击')">按钮4</button>
  66. <button class="button" onclick="showInfo('按钮5被点击')">按钮5</button>
  67. <button class="button" onclick="showInfo('按钮6被点击')">按钮6</button>
  68. </div>
  69. <div class="right-panel">
  70. <div id="info"></div>
  71. <button class="interactive-button" onclick="showMessage()">交互按钮</button>
  72. <input type="text" id="input" placeholder="在这里输入文本">
  73. </div>
  74. </div>
  75. <script>
  76. function showInfo(text) {
  77. document.getElementById("info").textContent = text;
  78. }
  79. function showMessage() {
  80. var inputText = document.getElementById("input").value;
  81. alert(inputText);
  82. }
  83. </script>
  84. </body>
  85. </html>