如何移除inline-block元素之间的空格?

如何移除inline-block元素之间的空格?

我们可以轻松删除内联块元素之间的空格。在继续之前,让我们首先创建一个 HTML 文档并添加带空格的内联块元素 –

示例

   Inline block elements         li {         display: inline-block;         width: 150px;         font-size: 18px;      }      li:nth-child(1) {         background: green;         color: white;      }      li:nth-child(2) {         background: orange;         color: black;      }      li:nth-child(3) {         background: blue;         color: white;      }      li:nth-child(4) {         background: red;         color: black;      }      

Free Tutorials

We have the following tutorials right now:

  • Java
  • Python
  • Machine Learning
  • Automation

现在让我们看一些删除内联块元素之间的空格的示例 –

删除内联块元素之间的空格

我们可以通过将无序列表项排列在一行中来删除内联块元素之间的空格 –

示例

   Inline block elements         li {         display: inline-block;         width: 150px;         font-size: 18px;      }      li:nth-child(1) {         background: green;         color: white;      }      li:nth-child(2) {         background: orange;         color: black;      }      li:nth-child(3) {         background: blue;         color: white;      }      li:nth-child(4) {         background: red;         color: black;      }      

Free Tutorials

We have the following tutorials right now:

  • Java
  • Python
  • Machine Learning
  • Automation

通过跳过结束标记来删除内联块元素之间的空格

我们还可以通过跳过分类标签来删除空格 –

示例

   Inline block elements         li {         display: inline-block;         width: 150px;         font-size: 18px;      }      li:nth-child(1) {         background: green;         color: white;      }      li:nth-child(2) {         background: orange;         color: black;      }      li:nth-child(3) {         background: blue;         color: white;      }      li:nth-child(4) {         background: red;         color: black;      }      

Free Tutorials

We have the following tutorials right now:

  • Java
  • Python
  • Machine Learning
  • Automation

以上就是如何移除inline-block元素之间的空格?的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1552196.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月21日 22:22:21
下一篇 2025年12月21日 22:22:40

发表回复

登录后才能评论
关注微信