删除HTML,CSS中按钮之间的空格

前端之家收集整理的这篇文章主要介绍了删除HTML,CSS中按钮之间的空格前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想删除按钮之间的空格,以便当我将鼠标悬停在NORMAL按钮上时,它与HARD按钮之间不会有空格.我该怎么做?这些空白区域来自哪里?
  1. body {
  2. margin: 0;
  3. }
  4. #stripe {
  5. background-color: white;
  6. text-align: center;
  7. height: 50px;
  8. color: black;
  9. }
  10.  
  11. button {
  12. border: none;
  13. background: none;
  14. text-transform: uppercase;
  15. height: 100%;
  16. font-weight: 700;
  17. color: black;
  18. letter-spacing: 1px;
  19. font-size: inherit;
  20. transition: all 0.3s;
  21. outline: none;
  22. }
  23.  
  24. button:hover {
  25. color: white;
  26. background: black;
  27. }
  28.  
  29. .selected {
  30. color: white;
  31. background: black;
  32. }
  1. <div id="stripe">
  2. <button class="mode">Easy</button>
  3. <button class="mode">Normal</button>
  4. <button class="mode selected">Hard</button>
  5. </div>

解决方法

删除空格和回车符,或在它们之间放置HTML注释.
  1. body {
  2. margin: 0;
  3. }
  4. #stripe {
  5. background-color: white;
  6. text-align: center;
  7. height: 50px;
  8. color: black;
  9. }
  10.  
  11. button {
  12. border: none;
  13. background: none;
  14. text-transform: uppercase;
  15. height: 100%;
  16. font-weight: 700;
  17. color: black;
  18. letter-spacing: 1px;
  19. font-size: inherit;
  20. transition: all 0.3s;
  21. outline: none;
  22. }
  23.  
  24. button:hover {
  25. color: white;
  26. background: black;
  27. }
  28.  
  29. .selected {
  30. color: white;
  31. background: black;
  32. }
  1. <div id="stripe">
  2. <button class="mode">Easy</button><!--
  3. --><button class="mode">Normal</button><!--
  4. --><button class="mode selected">Hard</button>
  5. </div>

猜你在找的HTML相关文章