
我们可以轻松删除内联块元素之间的空格。在继续之前,让我们首先创建一个 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元素之间的空格?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号