【发布时间】:2020-03-25 15:53:34
【问题描述】:
我想在主页、关于和其他按钮之间添加更多空间。至少大约 5px。
这是我的 HTML 和 CSS 代码:
.custom-padding{
padding-top: 25px;
}
nav {
border-radius: 20px;
background: #ededf1;
box-shadow: 5px 5px 10px #8e8e91,
-5px -5px 10px #ffffff;
position: relative;
width: calc(100% - 60px);
margin: 0 auto;
padding: 10px;
z-index: 1;
text-align: right;
padding-right: 2%;
}
.menu-area li {
display: inline-block;
border-radius: 10px;
background: #ededf1;
box-shadow: 3px 3px 5px #8e8e91,
-3px -3px 5px #ffffff;
}
.menu-area a {
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
font-weight: bold;
text-decoration: none;
color: #8c93a4;
letter-spacing: 1px;
text-transform: capitalize;
display: block;
padding: 0 30px;
font-size: 15px;
line-height: 30px;
position: relative;
z-index: 1;
}
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css">
<title>
some title
</title>
</head>
<body >
<div class="custom-padding">
<nav>
<div class="logo">Form</div>
<ul class="menu-area">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Services</a></li>
</ul>
</nav>
</div>
</body>
</html>
【问题讨论】:
-
那为什么不加边距呢?
-
margin 在这里不好用,它给底部增加了空间
-
或者只是让按钮变长或变高,我需要在它们之间添加空间,而不是让它们变大
-
margin-left: 5px对我来说似乎工作正常 -
假设您删除了
ul上的默认边距/填充
标签: html css list html-lists