我们可以轻松删除内联块元素之间的空格。在继续之前,让我们首先创建一个 html 文档并添加带空格的内联块元素 -
示例<!doctype html><html><head> <title>inline block elements</title> <style> 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; } </style></head><body> <h1>free tutorials</h1> <p>we have the following tutorials right now:</p> <ul> <li>java</li> <li>python</li> <li>machine learning</li> <li>automation</li> </ul></body></html>
现在让我们看一些删除内联块元素之间的空格的示例 -
删除内联块元素之间的空格我们可以通过将无序列表项排列在一行中来删除内联块元素之间的空格 -
示例<!doctype html><html><head> <title>inline block elements</title> <style> 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; } </style></head><body> <h1>free tutorials</h1> <p>we have the following tutorials right now:</p> <ul> <li>java</li><li>python</li><li>machine learning</li><li>automation</li> </ul></body></html>
通过跳过结束标记来删除内联块元素之间的空格我们还可以通过跳过分类标签来删除空格 -
示例<!doctype html><html><head> <title>inline block elements</title> <style> 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; } </style></head><body> <h1>free tutorials</h1> <p>we have the following tutorials right now:</p> <ul> <li>java <li>python <li>machine learning <li>automation </ul></body></html>
以上就是如何移除inline-block元素之间的空格?的详细内容。