简单 计算器应用程序风格 Bootstrap程序5

  • 源码大小:5.89KB
  • 所需积分:1积分
  • 源码编号:19JP-3387
  • 浏览次数:566次
  • 最后更新:2023年06月07日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

在这篇文章中,我们将使用最新的Bootstrap 5框架制作一个简单的在线计算器应用程序。

这是一款只接受十进制数字的计算器应用程序。这将帮助您开始使用Bootstrap 5,并了解如何将其风格融入您自己的应用程序中。

如何使用它:

1.在文档中加载所需的jQuery库和Bootstrap 5样式表。

  1. <link rel="stylesheet" href="/path/to/cdn/bootstrap.min.css" />
  2. <script src="/path/to/cdn/jquery.slim.min.js"></script>

2.为计算器创建HTML,并使用Bootstrap的按钮实用程序类设置按钮样式:

  1. <div class="calculator-area mx-auto justify-content-center border border-primary text-center">
  2. <div class="history col-12">
  3. <div class="logo">
  4. jQueryScript.Net
  5. </div>
  6. <div class="below-logo">
  7. <input type="text" class="border border-primary form-control-sm text-center history-screen" disabled/>
  8. </div>
  9. </div>
  10. <div class="row">
  11. <input type="text" class="input-screen border border-primary form-control-lg col-9 text-end" disabled/>
  12. <button type="button" class="btn btn-outline-danger reset col" value="reset">RESET</button>
  13. </div>
  14. <div class="row">
  15. <button type="button" class="btn btn-outline-secondary col" value="7">7</button>
  16. <button type="button" class="btn btn-outline-secondary col" value="8">8</button>
  17. <button type="button" class="btn btn-outline-secondary col" value="9">9</button>
  18. <button type="button" class="btn btn-outline-primary col" value="+">+</button>
  19. </div>
  20. <div class="row">
  21. <button type="button" class="btn btn-outline-secondary col" value="4">4</button>
  22. <button type="button" class="btn btn-outline-secondary col" value="5">5</button>
  23. <button type="button" class="btn btn-outline-secondary col" value="6">6</button>
  24. <button type="button" class="btn btn-outline-primary col" value="-">-</button>
  25. </div>
  26. <div class="row">
  27. <button type="button" class="btn btn-outline-secondary col" value="1">1</button>
  28. <button type="button" class="btn btn-outline-secondary col" value="2">2</button>
  29. <button type="button" class="btn btn-outline-secondary col" value="3">3</button>
  30. <button type="button" class="btn btn-outline-primary col" value="x">x</button>
  31. </div>
  32. <div class="row">
  33. <button type="button" class="btn btn-outline-secondary col mod" value="%">mod</button>
  34. <button type="button" class="btn btn-outline-secondary col" value="0">0</button>
  35. <button type="button" class="btn btn-outline-secondary col" value=".">.</button>
  36. <button type="button" class="btn btn-outline-primary col" value="/">&divide;</button>
  37. </div>
  38. <div class="row">
  39. <button type="button" class="btn btn-outline-success col-8" value="=">=</button>
  40. <button type="button" class="btn btn-outline-primary col-3" value="+-">+/-</button>
  41. </div>
  42. </div>

3.计算器的附加CSS样式。

  1. .input-screen {
  2. background-color: rgb(195, 247, 247);
  3. font-size: 2vw;
  4. }
  5.  
  6. .calculator-area {
  7. width: 70%;
  8. height: 90%;
  9. margin: 6%;
  10. padding: 3%;
  11. background-color: #dfdddd;
  12. }
  13.  
  14. .history-screen {
  15. background-color: #c7c7c7;
  16. font-size: 1.6vw;
  17. max-width: 50%;
  18. }
  19.  
  20. .row {
  21. margin: 1%;
  22. padding: 1%;
  23. }
  24.  
  25. .btn {
  26. margin: 1%;
  27. font-size: xx-large;
  28. }
  29.  
  30. .reset {
  31. font-size: 15px;
  32. font-weight: bolder;
  33. }
  34.  
  35. .mod {
  36. font-size: medium;
  37. font-weight: bolder;
  38. }
  39.  
  40. .btn-outline-secondary {
  41. background: linear-gradient(to right, #000000 0%, #000000 50%, #ffffff 50%, #ffffff 100%);
  42. background-size: 200% 100%;
  43. background-position: 100% 0;
  44. transition: background-position 0.1s;
  45. -webkit-transition: all 1s;
  46. -moz-transition: all 1s;
  47. transition: all 1s;
  48. color: #000000;
  49. }
  50.  
  51. .btn-outline-secondary:hover {
  52. background-position: 0 0;
  53. }
  54.  
  55. .btn-outline-secondary:focus {
  56. color: #000000;
  57. }
  58.  
  59. .btn-outline-danger {
  60. background: linear-gradient(to right, #f87171 0%, #f87171 50%, #ff0000 50%, #ff0000 100%);
  61. background-size: 200% 100%;
  62. background-position: 100% 0;
  63. transition: background-position 0.1s;
  64. -webkit-transition: all 1s;
  65. -moz-transition: all 1s;
  66. transition: all 1s;
  67. color: #000000;
  68. }
  69.  
  70. .btn-outline-danger:hover {
  71. background-position: 0 0;
  72. }
  73.  
  74. .btn-outline-danger:focus {
  75. color: white;
  76. }
  77.  
  78. .outer {
  79. margin: 0;
  80. padding: 0;
  81. }

4.启用计算器。

  1. <script src="js/app.js"></script>

更新日志:

2022-09-25

  • JS和CSS已更新

预览截图