html - 如何创建线条来分隔菜单中的元素?

标签 html css menu lines

我想创建 3 条白线,每条白线单独分隔菜单栏中的“家”、“关于我”和“我喜欢什么”。我已经为边框创建了线条,但我发现很难用 1px 纯白色将元素本身分开。任何帮助,将不胜感激。谢谢。

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>It's all about me!</title>
</head>
<body>
<header>
  <img src="me.jpg" alt="devon">
</div>
<h1>Ben's blog</h1>
<div class="grow">
<ul>
  <li><a href="index.html">Home</a></li>
  <li><a href="aboutme.html">About me</a></li>
  <li><a href="#">What I love</a></li>
</ul>
</div>
</header>
</body>
</html>
           ------------------(CSS below, in another file)-------------------------
body {
    background-image: url(background.jpg);
}


header {
    text-align: center;
    color: white;
}
img {
    border: 7px solid white;
    border-radius: 15px;

}

a {
    color: white;
    text-decoration: none;
    font-weight: bold;
}
ul {
    padding: 10px;
    background: black;
    border-right: 1px solid white;
    border-left: 1px solid white;


}

li {
    display: inline;
    padding: 0px 15px 0px 15px;
}

.grow {
  display: inline-block;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-property: -webkit-transform;
  transition-property: transform;
  -webkit-transform: translateZ(0);
  -ms-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
}

.grow:hover {
  -webkit-transform: scale(1.1);
  -ms-transform: scale(1.1);
  transform: scale(1.1);
}

最佳答案

只需使用以下内容:

ul li:not(:last-child){
    border-right:1px solid white;
}

如果您希望有尾随行,请删除 :not(:last-child)

关于html - 如何创建线条来分隔菜单中的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25185481/

相关文章:

c# - 如何根据asp.net母版页中的用户权限从菜单中删除项目

javascript - 隐藏正文直到它完成加载

html - 由于 css3 hight vh 属性,无法向下滚动和查看文本

css - 如何将一个 div 包裹在同级 div 周围

php - 在第二个 while 循环内进行 while 循环以获取子类别

html - 使一个 div 元素弹出它的父元素有溢出 :auto

html - css如何在自动调整宽度时将一个div依赖于另一个div

javascript - 有一个使用 html5 的网络作品 "hello world "演示

javascript - 为什么我的按钮将事件传播到其父级?

html - 让我的 div 转到页面底部