1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <title></title>
    5. <meta charset="utf-8" />
    6. <style type="text/css">
    7. html,body{
    8. width:590px;
    9. height:590px;
    10. margin:0px;
    11. }
    12. #cont{
    13. width:100%;
    14. height:50px;
    15. line-height:50px;
    16. }
    17. input{
    18. background-color: #4CAF50; /* Green */
    19. width:80px;
    20. height:30px;
    21. border: none;
    22. color: white;
    23. padding: 5px 5px;
    24. text-align: center;
    25. text-decoration: none;
    26. display: inline-block;
    27. font-size: 14px;
    28. cursor:pointer;
    29. }
    30. /* 样式一 */
    31. .styleOne{
    32. background-color:#FF7F24;
    33. width:300px;
    34. height:400px;
    35. border-radius:8px;
    36. }
    37. /* 样式二 */
    38. .styleTwo{
    39. background-color:#AFEABC;
    40. width:400px;
    41. height:500px;
    42. border-radius:8px;
    43. }
    44. </style>
    45. <script type="text/javascript">
    46. function styleOne(){
    47. document.getElementById("content").className="styleOne";
    48. }
    49. function styleTwo(){
    50. document.getElementById("content").className="styleTwo"
    51. }
    52. </script>
    53. </head>
    54. <body>
    55. <div id="cont">
    56. <input type="button" value="样式一" id="btn1" onclick="styleOne()"/>
    57. <input type="button" value="样式二" id="btn2" onclick="styleTwo()"/>
    58. </div>
    59. <div id="content"></div>
    60. </body>
    61. </html>