Larger gap between first and second elements in a list - html

In the list below, the spans do not line up to the center of their corresponding dots. I believe this is caused by the larger gap between the first and second spans.
HTML
<nav class="side-nav-right">
<ul>
<li class="bullet">
<a data-scroll href="#center-splash"><span style="width: 66px; left: -80px;">Intro</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section1"><span style="width: 66px; left: -80px;">section1</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section2"><span style="width: 66px; left: -80px;">section2</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section3"><span style="width: 66px; left: -80px;">section3</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section4"><span style="width: 66px; left: -80px;">section4</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section5"><span style="width: 66px; left: -80px;">section5</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section6"><span style="width: 66px; left: -80px;">section6</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section7"><span style="width: 66px; left: -80px;">section7</span></a>
</li>
</ul>
</nav>
SCSS
.side-nav-right {
display: block;
position: fixed;
top: 20%;
right: 1rem;
ul {
list-style: none outside;
li {
margin-bottom: 1rem;
a {
color: transparent;
display: block;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: $light-text;
box-shadow: inset 0.025rem 0.025rem 0.075rem $PG-red;
vertical-align: top;
&.active {
background: #808080;
box-shadow: none;
}
}
span {
color: $light-text;
position: absolute;
background: rgba(0,0,0,0.7);
display: none;
padding: 0.25rem 0.5rem;
border-radius: 3px;
vertical-align: middle;
}
span:before {
content:"";
display:block;
width:0;
height:0;
border:solid 5px;
border-color:transparent transparent transparent rgba(0,0,0,0.7);
position:absolute;
right:-10px;
top:9px
}
&:hover span {
display: block;
}
}
li:first-child a>span{top:-5px}
}
}
#media only screen and (min-width: 1025px) {
.side-nav-right {
top: 30%;
right: 2rem;
ul {
li {
margin-bottom: 1.5rem;
a {
width: 1.25rem;
height: 1.25rem;
}
}
}
}
}
vertical-align seems to do nothing, commenting out all margins and padding doesn't work. I'm at a loss for why these elements aren't lining up past the first one.

You're looking at it the other way around. Notice that only your first element has a specific top property set to it:
li:first-child a>span{top:-5px}
The others do not.
Just align the others, and have the first one adjusted.
In this Fiddle I gave a margin-top to all spans and removed the special treatment for the first child. Might only be working on this fiddle and your exact measurements might need some adjustments, if so correct the fiddle.
span {
color: black;
position: absolute;
background: rgba(0,0,0,0.7);
display: none;
padding: 0.25rem 0.5rem;
border-radius: 3px;
vertical-align: middle;
margin-top: -8px;
}

Here is the solution without affecting your original code structure:
Replace your html with followg code:
<nav class="side-nav-right">
<ul>
<li class="bullet">
<a data-scroll href="#center-splash"><span>Intro</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section1"><span>section1</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section2"><span>section2</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section3"><span>section3</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section4"><span>section4</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section5"><span>section5</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section6"><span>section6</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section7"><span>section7</span></a>
</li>
</ul>
</nav>
Then replace your css with following code:
.side-nav-right {
display: block;
position: fixed;
top: 20%;
right: 1rem;
ul {
list-style: none outside;
li {
margin-bottom: 1rem;
position:relative;
a {
color: transparent;
display: block;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: $light-text;
box-shadow: inset 0.025rem 0.025rem 0.075rem $PG-red;
vertical-align: top;
&.active {
background: #808080;
box-shadow: none;
}
}
span {
color: $light-text;
position: absolute;
background: rgba(0,0,0,0.7);
display: none;
padding: 0.25rem 0.5rem;
border-radius: 3px;
vertical-align: middle;
width: 66px;
left: -90px;
top:-4px;
}
span:before {
content:"";
display:block;
width:0;
height:0;
border:solid 5px;
border-color:transparent transparent transparent rgba(0,0,0,0.7);
position:absolute;
right:-10px;
top:9px
}
&:hover span {
display: block;
}
}
li:first-child a>span{top:-5px}
}
}
#media only screen and (min-width: 1025px) {
.side-nav-right {
top: 30%;
right: 2rem;
ul {
li {
margin-bottom: 1.5rem;
a {
width: 1.25rem;
height: 1.25rem;
}
}
}
}
}

Related

How to delete this space between the logo and list items in the nav bar?

I want the navigation bar items to align left next to the logo, but am unable to achieve this.
Does anyone know what is going on?
What it looks like:
The space I want gone:
My HTML code:
<nav id="nav-bar">
<img src="https://assets.codepen.io/7471668/logo+pic.png" id="header-img" alt="company-logo" />
<ul class="nav__menu">
<li class="nav__item">
<a class="nav-link" href="">Options</a></li>
<li class="nav__item">
<a class="nav-link" href="">How it works</a></li>
<li class="nav__item">
<a class="nav-link" href="">Sign-up</a></li
</ul>
</nav>
My CSS:
#nav-bar {
display: flex;
position: fixed;
left: 0;
width: 100%;
background-color: rgba(0, 0, 0, 1);
}
.nav__menu {
display: flex;
font-size: 0.95rem;
}
.nav__item {
margin-right: 3rem;
font-family: archivo;
}
.nav-link {
color: white;
text-decoration: none;
}
.nav-link:hover,
.nav-link:focus-visible {
box-shadow: 0 4px 0 -1px #FFF;
}
#header-img {
width: 25%;
margin-top: 6px;
margin-left: 10px;
margin-right: 0;
}
#nav-bar {
display: flex;
position: fixed;
left: 0;
width: 100%;
background-color: rgba(0, 0, 0, 1);
}
.nav__menu {
display: flex;
font-size: 0.95rem;
}
.nav__item {
margin-right: 3rem;
font-family: archivo;
}
.nav-link {
color: white;
text-decoration: none;
}
.nav-link:hover,
.nav-link:focus-visible {
box-shadow: 0 4px 0 -1px #FFF;
}
#header-img {
/* from width:25% */
width: 100px; /*Use px*/
margin-top: 6px;
margin-left: 10px;
margin-right: 0;
}
<nav id="nav-bar">
<img src="https://assets.codepen.io/7471668/logo+pic.png" id="header-img" alt="company-logo" />
<ul class="nav__menu">
<li class="nav__item">
<a class="nav-link" href="">Options</a></li>
<li class="nav__item">
<a class="nav-link" href="">How it works</a></li>
<li class="nav__item">
<a class="nav-link" href="">Sign-up</a></li
</ul>
</nav>
I provided a snippet please do check if it is the output you are looking for.
Simply use "px" to resize the width of your image.
I changed width: 25%; to width: 100px;

How to add small circle in the bottom boarder using CSS with the line border

I would like to add a small circle under menu item using CSS like the picture below:
and here what I did so far:
And this is the HTML:
<ul>
<li class="nav-item">
VISION
</li>
<li class="nav-item">
CULTURE
</li>
<li class="nav-item">
SPACE
</li>
<li class="nav-item">
CONTACT US
</li>
</ul>
here is the "nav-item" CSS:
.nav-item {
font-family:"Geometria-Light";
font-size: 12px;
border-bottom: .2px solid #C29B4C;
color:#FFFFFF!important;
}
and here is the "active" CSS:
.active{
border-bottom: .2px solid #C29B4C;
color:#C29B4C !important;
}
Can anyone explain to me how can I achieve this?
Here's an example
ul {
display: flex;
}
.nav-item {
list-style: none;
padding: 5px 10px;
border-bottom: .2px solid #C29B4C;
margin: 0;
}
.nav-link {
font-family: "Geometria-Light";
font-size: 12px;
margin: 0;
text-decoration: none;
}
.item-active {
position: relative;
}
.item-active a {
color: #C29B4C !important;
}
.item-active:before {
content: '';
height: 8px;
width: 8px;
background-color: #C29B4C;
border-radius: 50%;
display: inline-block;
position: absolute;
bottom: -4px;
left: 50%;
}
<ul>
<li class="nav-item">
it0
</li>
<li class="nav-item item-active">
VISION
</li>
<li class="nav-item">
it2
</li>
</ul>
Update your nav-item with .dot class
<li class="nav-item">
VISION
<span class="dot"></span>
</li>
here is .class css code
.item-active .dot {
height: 25px;
width: 25px;
background-color: #C29B4C;
border-radius: 50%;
display: inline-block;
margin-top: 40px;
position: absolute;
text-align: center;
}
i think it will be work for you

Why are my drop downs opening automatically when resizing to smaller screen size?

For a mobile view, this is the expected outcome
For some reason, when I resize the window all of my drop down menu items are opened. I want it too look like to posted image and when the headers are clicked the menu opens up to the drop downs on small screens. Link to my code here: https://jsfiddle.net/ept307gm/
<div id="menuContainer" class="clearfix">
<nav id="siteMenu">
<h2 class="mobileTitle"> <img style="float: right;" src=""></h2>
<ul class="dropDownMenu">
<li id="dropDownRootItem1">
<a class="dropDownRootItem1">Information</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<ul class="menuLevel1">
<li class="menuLevel2">My Account</li>
To begin with, you need to hide the submenus in the media query for smaller devices
#siteMenu, .menuColumn {
display: none;
}
Subsequently, you can use some basic JavaScript to toggle the submenu on menu item click.
Below is the working snippet:
var listItems = document.querySelectorAll('.dropDownMenu > li');
for (let listItem of listItems) {
listItem.onclick = e => {
var subMenu = e.target.querySelector('.menuColumn');
if (window.getComputedStyle(subMenu).display === 'none') {
subMenu.style.display = 'block';
} else {
subMenu.style.display = 'none';
}
}
}
div,
a,
img,
nav {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
nav {
display: block;
}
h2 {
padding: 0;
margin: 0 0 10px 0;
font-size: 24px;
font-weight: bold;
color: #323232;
}
a,
a:visited {
color: #4f2683;
text-decoration: none;
}
a:active,
a:hover {
text-decoration: underline;
}
ul {
margin-bottom: 20px;
margin-top: -5px;
}
ul ul {
margin: 0;
}
a {
font-weight: 700;
}
#media handheld,
screen and (min-width: 620px) {
#menuContainer ul {
list-style: none;
}
#menuContainer {
float: left;
max-width: 821px;
width: 100%;
margin: 0;
padding-top: 20px;
margin-bottom: -20px;
}
#siteMenu .mobileTitle {
display: none;
}
#siteMenu {
height: 60px;
position: relative;
list-style: none;
font-size: 14px;
z-index: 6000;
box-shadow: none;
margin: 0;
padding: 0 0 0 10px;
}
.dropDownMenu {
position: relative;
z-index: 999;
list-style: none;
margin: 0;
padding: 0;
}
.dropDownMenu>li>a {
display: block;
overflow: hidden;
position: relative;
text-indent: 0;
color: #000;
text-align: center;
text-decoration: none;
background: 0;
border: 0 none;
height: auto;
padding: 15px 0;
font-weight: 400;
}
.dropDownMenu ul {
list-style-type: none;
float: left;
position: relative;
z-index: 9999;
margin: 0;
padding: 0;
}
ul.menuColumn {
border-left: none;
border-right: none;
}
ul.menuColumn:first-child {
border: 0;
}
.widthcontainer2col ul.menuColumn {
width: 45%;
padding: 0 10px;
}
.dropDownMenu ul.menuColumn a {
text-decoration: none;
display: block;
letter-spacing: 1px;
color: #363636;
font-size: 13px;
line-height: 115%;
margin: 6px 0;
}
.dropDownMenu li.menuLevel1 {
font-weight: 700;
letter-spacing: 0;
font-size: 12px;
line-height: 16px;
color: #4f2683;
margin: 5px 0;
}
.dropDownMenu li.menuLevel2>a {
font-weight: 400;
}
.dropDownMenu ul a:hover {
text-decoration: underline;
}
.dropDownMenu ul.menuLevel1 {
float: none;
}
.dropDownMenu .menuContainer {
position: absolute;
display: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.4);
-webkit-box-shadow: 0 4px 4px rgba(0, 0, 0, 0.4);
border: 1px solid #4f2683;
background: #fff;
z-index: 9999;
top: 47px;
padding: 0;
}
.dropDownMenu .innerContainer {
float: left;
width: 100%;
position: relative;
z-index: 99;
}
.dropDownMenu .widthcontainer2col {
width: 50%;
}
ul.dropDownMenu li:hover .menuContainer {
display: block!important;
}
ul.dropDownMenu li {
float: left;
cursor: pointer;
}
ul.dropDownMenu li li {
float: none;
}
.widthcontainer2col {
top: 30px;
z-index: 999;
}
/* .widthcontainer2col .innerContainer:before {
position: absolute;
content: "";
z-index: -1;
width: 53%;
top: 12px;
bottom: 14px;
right: 0;
border-left: 1px solid #b9b9b9;
} */
/* .dropDownMenu>li:hover>a {
position: relative;
text-decoration: none;
font-weight: 700;
background: #4f2683;
color: #fff;
} */
#dropDownRootItem2 {
width: 19.970631424376%;
max-width: 136px;
}
#dropDownRootItem2:hover>a {
background-position: center -21px;
}
#dropDownRootItem3:hover>a {
background-position: center -63px;
}
#dropDownRootItem4 {
width: 15.418502202643%;
max-width: 105px;
}
#dropDownRootItem4:hover>a {
background-position: center -105px;
}
#dropDownRootItem5 {
width: 16.446402349486%;
max-width: 90px;
}
#dropDownRootItem5:hover>a {
background-position: center -147px;
}
#dropDownRootItem7 .widthcontainer2col {
right: 0;
}
#dropDownRootItem1,
#dropDownRootItem3 {
width: 17.033773861968%;
max-width: 116px;
}
#dropDownRootItem6,
#dropDownRootItem7 {
width: 16.096916299559%;
max-width: 124px;
}
#dropDownRootItem7 {
width: 16.096916299559%;
max-width: 124px;
}
#dropDownRootItem6:hover>a,
#dropDownRootItem7:hover>a {
background-position: center -189px;
}
#dropDownRootItem5,
#dropDownRootItem6,
#dropDownRootItem7 {
position: relative;
}
#dropDownRootItem5 .widthcontainer2col,
#dropDownRootItem6 .widthcontainer2col,
#dropDownRootItem7 .widthcontainer2col {
width: 440px;
}
.widthcontainer2col .innerContainer:before {
position: relative;
border-left: none;
}
.innerContainer>.menuColumn:nth-child(1) {
width: 100%;
box-sizing: border-box;
}
.dropDownMenu .widthcontainer2col {
width: auto;
}
#dropDownRootItem5 .widthcontainer2col,
#dropDownRootItem6 .widthcontainer2col,
#dropDownRootItem7 .widthcontainer2col {
width: 250px;
}
.dropDownMenu .menuLevel2 {
padding: 3px 0;
}
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
}
#media screen and (max-width: 840px) {
#dropDownRootItem1 {
width: 17%;
}
#dropDownRootItem2 {
width: 16%;
}
#dropDownRootItem3 {
width: 14%;
}
#dropDownRootItem4 {
width: 13%;
}
#dropDownRootItem5 {
width: 12%;
}
#dropDownRootItem6 {
width: 10%;
}
#dropDownRootItem7 {
width: 10%;
}
}
#media screen and (max-width: 740px) {
#dropDownRootItem1,
#dropDownRootItem2,
#dropDownRootItem3,
#dropDownRootItem4,
#dropDownRootItem5,
#dropDownRootItem6,
#dropDownRootItem7 {
font-size: 12px;
}
}
#media handheld,
screen and (max-width: 619px) {
#siteMenu,
.menuColumn {
display: none;
}
#siteMenu {
display: block;
}
#siteMenu .mobileTitle {
display: block;
padding: 15px;
padding-left: 30px;
background-color: #4f2683;
color: #fff;
box-sizing: border-box;
cursor: pointer;
}
#siteMenu>ul {
list-style-type: none;
width: 89.5%;
padding: 0;
margin: 0 auto;
margin-bottom: 10px;
box-sizing: border-box;
transition: all .5s ease;
}
#siteMenu>ul ul {
padding: 0;
list-style: none;
}
#siteMenu a,
#siteMenu li {
margin: 0;
padding: 15px 10px;
color: #fff;
}
#siteMenu .dropDownMenu>li {
width: 100%!important;
box-sizing: border-box;
padding: 5px 0;
cursor: pointer;
}
.dropDownMenu>li>a {
font-size: 24px;
background-color: #4f2683;
display: block;
margin: 10px;
pointer-events: none;
}
.dropDownMenu>li>.menuContainer {
font-size: 16px;
width: 100%;
height: 100%;
}
.dropDownMenu>li>.menuContainer>.innerContainer {
opacity: .75;
}
#siteMenu .menuColumn>li {
padding: 0;
background-color: #fff;
color: #4f2683;
}
#siteMenu .menuColumn li a {
color: #4f2683;
}
#siteMenu li.menuLevel2 {
padding-left: 0;
}
#siteMenu .menuColumn>li>ul {
padding: 0;
}
#siteMenu .menuColumn>li>ul>li {
padding-left: 0;
margin: 2px;
}
#siteMenu .menuLevel2 {
padding: 15px;
}
}
#media print {
#siteMenu {
display: none;
}
h2 {
color: #000;
font-size: 25px;
}
img {
border: none;
}
}
<div id="menuContainer" class="clearfix">
<nav id="siteMenu">
<h2 class="mobileTitle"> <img style="float: right;" src=""></h2>
<ul class="dropDownMenu">
<li id="dropDownRootItem1">
<a class="dropDownRootItem1">Information</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<ul class="menuLevel1">
<li class="menuLevel2">My Account</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">About</li>
<li class="menuLevel2">Blog</li>
<li class="menuLevel2">Contact Us</li>
</ul>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem2">
<a class="dropDownRootItem1">Kids' Corner</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<!-- Kids' Corner is currently under construction -->
<!-- <li class='menuLevel2'><a href='/kids-corner-home'>Kids' Corner</a></li> -->
<li class="menuLevel2">Kids' Programs</li>
<li class="menuLevel2">Story Times</li>
<li class="menuLevel2">Program Registration</li>
<li class="menuLevel2">Kids’ Annual Programs</li>
<li class="menuLevel2">Books and Kits for Kids</li>
<li class="menuLevel2">Online Resources</li>
<li class="menuLevel2">Kids’ Calendar</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem3">
<a class="dropDownRootItem1">Teen Scene</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Teen Programs</li>
<li class="menuLevel2">Teen Homework Resources</li>
<li class="menuLevel2">Teen Booklists</li>
<li class="menuLevel2">Teen Magazines</li>
<li class="menuLevel2">Teen Newsletter</li>
<li class="menuLevel2">Teen Calendar</li>
<li class="menuLevel2">Contact a Teen Librarian</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem4">
<a class="dropDownRootItem1">Programs</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Calendar </li>
<li class="menuLevel2">All Ages Programs</li>
<li class="menuLevel2">Adult Programs</li>
<li class="menuLevel2">Teen Programs</li>
<li class="menuLevel2">Kids’ Programs</li>
<li class="menuLevel2">Annual Programs</li>
<li class="menuLevel2">Exhibits </li>
<li class="menuLevel2">On Demand Programs</li>
<li class="menuLevel2">Other Programs</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem5">
<a class="dropDownRootItem1">Learn</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Research Databases</li>
<li class="menuLevel2">Homework Resources</li>
<li class="menuLevel2">Educational Services</li>
<li class="menuLevel2">Computers, Internet & Printing</li>
<li class="menuLevel2">Private Study Rooms</li>
<li class="menuLevel2">Media Center</li>
<li class="menuLevel2">Basement Creative Lab</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem6">
<a class="dropDownRootItem1">Books & Media</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Book Club Sets</li>
<li class="menuLevel2">Booklists</li>
<li class="menuLevel2">Library Book Blogs</li>
<li class="menuLevel2">Book Series Order</li>
<li class="menuLevel2">Reading Suggestions</li>
<li class="menuLevel2">Magazines & Newspapers</li>
<li class="menuLevel2">New Audio/Visual Materials</li>
<li class="menuLevel2">Requesting Books</li>
<li class="menuLevel2">Digital Collections</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem7">
<a class="dropDownRootItem1">Español</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Páginas en Español</li>
<li class="menuLevel2">Usando la Biblioteca</li>
<li class="menuLevel2">Servicios </li>
<li class="menuLevel2">Eventos</li>
<li class="menuLevel2">Recursos</li>
<li class="menuLevel2">Departamento de Niños</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
</ul>
</nav>
</div>

CSS border used as lines, but needs to stop after reaches last child

What's happening is the lines from a child are being drawn all the way down the page, even when that child is the last. I've tried all sorts of code to make the lines end at the last child.
I know this is not a lot of detail. I think the code will speak for itself.
I'm using an <ul><li><div></div></li></ul> model. Any help would be appreciated.
.blackbox {
width: 340px;
height: 100%;
padding: 5px;
background: #333A46;
}
body {
color: #444;
font-family: Segoe, 'Segoe UI', Calibri, Arial, sans-serif;
background: white;
font-size: 12px;
}
/* Framework start from here */
ul.tree,
ul.tree ul {
margin: 5;
padding: 0;
list-style: none;
}
ul.tree ul {
position: relative;
margin-left: 1px;
/* indentation */
}
ul.tree ul:before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
display: block;
width: 0;
border-left: 1px solid white;
}
ul.tree li {
position: relative;
margin: 0;
padding: 0 12px;
/* indentation + 2 */
font-size: 20px;
line-height: 50px;
/* default list item `line-height` */
}
/*left to right dash for line*/
ul.tree ul li:before {
content: '';
display: block;
width: 13px;
/* same with indentation */
height: 0;
border-top: 1px solid white;
position: absolute;
top: 31px;
left: 0;
}
.list-box-solid {
/*padding: 10px 10px 10px 10px;*/
background: white;
width: 240px;
height: 50px;
text-align: center;
}
.border-padding {
margin-left: 1px;
border-top: 5px #333A46 solid;
}
.list-box-dashed {
border: 2px dashed white;
color: white;
width: 240px;
height: 50px;
text-align: center;
}
ul.tree ul li:last-child:before {
background: white;
/* same with body background changed from auto to 1px*/
top: 31px;
/* line-height/2 */
bottom: 0;
}
<div class="blackbox">
<ul class="tree">
<li>
<div class="list-box-solid border-padding">University of Somewhere</div>
<ul>
<li>
<div class="list-box-solid border-padding">Birds</div>
</li>
<li>
<div class="list-box-solid border-padding">Mammals</div>
<ul>
<li>
<div class="list-box-solid border-padding">Elephant</div>
<ul>
<li>
<div class="border-padding">
<div class="list-box-dashed">+Create Group</div>
</div>
</li>
<li>
<div class="list-box-solid border-padding">List item 2</div>
</li>
<li>
<div class="list-box-solid border-padding">List item 3</div>
<ul>
<li>
<div class="list-box-solid border-padding">List item 3.1</div>
</li>
<li>
<div class="list-box-solid border-padding">List item 3.2</div>
</li>
<li>
<div class="list-box-solid border-padding">List item 3.3</div>
<ul>
<li>
<div class="list-box-solid border-padding">List item 3.3.1</div>
<ul>
<li>
<div class="list-box-solid border-padding">List item 3.3.1.1</div>
</li>
</ul>
</li>
</ul>
</li>
<li>
<div class="list-box-solid border-padding">List item 3.4</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul </div>
I solved it here.
Not sure what is different that caused it. I worked backwards from the original which didn't have the lines.
body {
font-family: Segoe, 'Segoe UI', Calibri, Arial, sans-serif;
}
/* Framework start from here */
ul.tree,
ul.tree ul {
margin: 0;
padding: 0;
list-style: none;
}
ul.tree ul {
position: relative;
margin-left: 1px;
/* indentation */
}
ul.tree ul:before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
display: block;
width: 0;
border-left: 1px solid;
color: white;
}
ul.tree li {
position: relative;
margin: 0;
padding: 0 12px;
/* indentation + 2 */
font-size: 14px;
line-height: 50px;
/* default list item `line-height` */
color: black;
}
ul.tree ul li:before {
content: '';
display: block;
width: 13px;
/* same with indentation */
height: 0;
border-top: 1px solid;
position: absolute;
top: 31px;
left: 0;
color: white;
}
ul.tree ul li:last-child:before {
background: #333A46;
/* same with body background */
height: auto;
top: 31px;
/* line-height/2 */
bottom: 0;
}
.blackbox {
width: 340px;
height: 100%;
padding: 5px;
background: #333A46;
}
.list-box-solid {
/*padding: 10px 10px 10px 10px;*/
background: white;
width: 240px;
height: 50px;
text-align: center;
}
.border-padding {
margin-left: 1px;
border-top: 5px #333A46 solid;
}
.list-box-dashed {
border: 2px dashed white;
color: white;
width: 240px;
height: 50px;
text-align: center;
}
<div class="blackbox">
<ul class="tree">
<li>
<div class="list-box-solid border-padding">Animals</div>
<ul>
<li>
<div class="list-box-solid border-padding">Birds</div>
</li>
<li>
<div class="list-box-solid border-padding">Birds</div>
<ul>
<li>
<div class="list-box-solid border-padding">Birds</div>
<ul>
<li>
<div class="list-box-solid border-padding">Birds</div>
</li>
<li>
<div class="list-box-solid border-padding">Birds</div>
</li>
<li>
<div class="list-box-solid border-padding">Birds</div>
<ul>
<li>
<div class="list-box-solid border-padding">Birds</div>
</li>
<li>
<div class="border-padding">
<div class="list-box-dashed">+Create Group</div>
</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
Use this:
li:last-child {
border-bottom: none;
}

Making a mini vertical divider

I am trying to make a miniature vertical bar like in this site, where they have the navigation and the vertical bars in between each link. I have tried the solution to a previous question, but when I tried to use 'margin-left' to move the text, the bar wouldn't stay between each link, it'd to this.
HTML
<div id="nav-clearfix">
<div id="nav">
<ul class="nav-pages">
<li>HOME</li>
<li><div class="mini-divider"></div></li>
<li>ROSTER</li>
<li><div class="mini-divider"></div></li>
<li>GALLERY</li>
<li><div class="mini-divider"></div></li>
<li>ABOUT US</li>
<li><div class="mini-divider"></div></li>
<li>SPONSORS</li>
</ul>
</div>
</div>
CSS
#nav-clearfix {
width: 100%;
height: 100px;
background: #000;
}
#nav {
margin-left: 10%;
width: 100%;
}
.nav-pages {
padding-top: 10px;
}
.mini-divider {
position: absolute;
top: 26%;
bottom: 71%;
border-left: 1px solid white;
}
.nav-pages li, .mini-divider {
float: left;
margin-left: 50px;
}
CSS
.nav-pages li:not(:last-child) a:after{
content: "";
/* width: 0px; */
background: white;
margin-left: 20px;
position: absolute;
height: inherit;
color: white;
border: 1px solid white;
height: 15px;
}
Remove The Border Related HTML & CSS
<li><div class="mini-divider"></div></li>
DEMO
You can also use + css selector to give border to the next element no need to add extra element for border
added
*{
margin: 0;
padding: 0;
}
for removing default styles given by browsers
* {
margin: 0;
padding: 0;
}
#nav-clearfix {
width: 100%;
height: 100px;
background: #000;
}
#nav {
width: 100%;
}
.nav-pages {
padding-top: 10px;
text-align:center;
}
.nav-pages li {
display: inline-block;
padding: 0 10px;
}
.nav-pages li + li {
border-left: 1px solid white;
}
<div id="nav-clearfix">
<div id="nav">
<ul class="nav-pages">
<li>HOME</li>
<li>ROSTER</li>
<li>GALLERY</li>
<li>ABOUT US</li>
<li>SPONSORS</li>
</ul>
</div>
</div>
Use this .separator class for vertical separator.
CSS
ul > li{
float: left;
display: block;
position: relative;
}
ul > li > a{
padding: 4px 6px;
display: block;
}
.separator {
background: none repeat scroll 0 0 #222;
border-left: 1px solid #333;
float: left;
height: 30px;
width: 1px;
}
HTML
<ul>
<li >
<a href="#" >Home</a>
</li> <span class="separator"></span>
<li> Link 1 </li> <span class="separator"></span>
<li > Link 2 </li> <span class="separator"></span>
<li> Link3 </li> <span class="separator"></span>
<li > Contact </li>
</ul>
jsfiddle: demo