有什么方法可以删除第 2 列之间的 space 吗?
Is there any way to delete those space between the 2 column?
希望你一切都好。虽然我感染了这种冠状病毒,但我正在努力提高我的网络技能。
我正在尝试制作一个只有 span/li/ul.
的 2 列 table
这是我的代码:
body {
background-color: #FEFAF6;
font-family: 'Segoe UI Regular';
font-size: 14px;
}
div.tableau_infor {
margin-left: auto;
margin-right: auto;
}
.fa-star {
color : #154360;
}
.all_star {
margin-left: 30px;
}
li {
list-style-type: none;
width: 365px;
}
li:hover {
background-color: red;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name ="author" content="Ismaël Zemmouj">
<link rel="shortcut icon" href="favicon.ico" type="">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link rel="stylesheet" href="test.css">
<title>mel</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6">
<ul>
<li>
<span class="">1bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">2bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-6">
<ul>
<li>
<span class="">3Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">4Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="row">
<div class="col-md-6">
<ul>
<li>
<span class="">5Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">6bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
您可以在下图中看到space。另外,我不知道为什么第二列的第一个和第二个元素之前有一个space...
我没有使用 table,因为使用 ul/il 进行响应式设计更容易,不是吗?
亲切地,
从 li
中删除固定宽度并使用 white-space:nowrap
代替,然后将 text-md-end
添加到第一列以避免间隙
body {
background-color: #FEFAF6;
font-family: 'Segoe UI Regular';
font-size: 14px;
}
.fa-star {
color : #154360;
}
.all_star {
margin-left: 30px;
white-space:nowrap;
}
li {
list-style-type: none;
display:inline-block;
}
li:hover {
background-color: red;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 text-md-end">
<ul>
<li>
<span class="">1bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">2bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-6 text-md-end">
<ul>
<li>
<span class="">3Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">4Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-6 text-md-end">
<ul>
<li>
<span class="">5Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">6bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
</div>
最后一行出现奇怪的缩进是因为您忘记关闭一个 <div>
标签。使用 HTML 验证器来查找这些类型的错误:https://validator.w3.org/#validate_by_input 您只需复制粘贴代码并单击“检查”按钮即可。
为了对元素进行超级响应控制,我会应用嵌套的网格行为。这是单行代码的示例:
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">1bcdeqgsterudisoqpardbfhert</div>
<div class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<span class="col-md-6">2bcdeqgsterudisoqpardbfhert</span>
<span class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</div>
</div>
</div>
编辑:三列解决方案示例:
<div class="row">
<div class="col-md-4">
<div class="row">
<div class="col-md-6">1bcdeqgsterudisoqpardbfhert</div>
<div class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</div>
</div>
</div>
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="row">
<span class="col-md-6">2bcdeqgsterudisoqpardbfhert</span>
<span class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</div>
</div>
</div>
希望你一切都好。虽然我感染了这种冠状病毒,但我正在努力提高我的网络技能。 我正在尝试制作一个只有 span/li/ul.
的 2 列 table这是我的代码:
body {
background-color: #FEFAF6;
font-family: 'Segoe UI Regular';
font-size: 14px;
}
div.tableau_infor {
margin-left: auto;
margin-right: auto;
}
.fa-star {
color : #154360;
}
.all_star {
margin-left: 30px;
}
li {
list-style-type: none;
width: 365px;
}
li:hover {
background-color: red;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name ="author" content="Ismaël Zemmouj">
<link rel="shortcut icon" href="favicon.ico" type="">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link rel="stylesheet" href="test.css">
<title>mel</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6">
<ul>
<li>
<span class="">1bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">2bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-6">
<ul>
<li>
<span class="">3Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">4Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="row">
<div class="col-md-6">
<ul>
<li>
<span class="">5Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">6bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
您可以在下图中看到space。另外,我不知道为什么第二列的第一个和第二个元素之前有一个space...
我没有使用 table,因为使用 ul/il 进行响应式设计更容易,不是吗?
亲切地,
从 li
中删除固定宽度并使用 white-space:nowrap
代替,然后将 text-md-end
添加到第一列以避免间隙
body {
background-color: #FEFAF6;
font-family: 'Segoe UI Regular';
font-size: 14px;
}
.fa-star {
color : #154360;
}
.all_star {
margin-left: 30px;
white-space:nowrap;
}
li {
list-style-type: none;
display:inline-block;
}
li:hover {
background-color: red;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 text-md-end">
<ul>
<li>
<span class="">1bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">2bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-6 text-md-end">
<ul>
<li>
<span class="">3Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">4Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-6 text-md-end">
<ul>
<li>
<span class="">5Abcdeqgsterudisoqpardbfher</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
<div class="col-md-6">
<ul>
<li>
<span class="">6bcdeqgsterudisoqpardbfhert</span>
<span class="all_star">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</li>
</ul>
</div>
</div>
</div>
最后一行出现奇怪的缩进是因为您忘记关闭一个
<div>
标签。使用 HTML 验证器来查找这些类型的错误:https://validator.w3.org/#validate_by_input 您只需复制粘贴代码并单击“检查”按钮即可。为了对元素进行超级响应控制,我会应用嵌套的网格行为。这是单行代码的示例:
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">1bcdeqgsterudisoqpardbfhert</div>
<div class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<span class="col-md-6">2bcdeqgsterudisoqpardbfhert</span>
<span class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</div>
</div>
</div>
编辑:三列解决方案示例:
<div class="row">
<div class="col-md-4">
<div class="row">
<div class="col-md-6">1bcdeqgsterudisoqpardbfhert</div>
<div class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</div>
</div>
</div>
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="row">
<span class="col-md-6">2bcdeqgsterudisoqpardbfhert</span>
<span class="col-md-6">
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
<span class="fas fa-star"></span>
</span>
</div>
</div>
</div>