Making a mini vertical divider - html

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

Related

Issue in overlapping of items in hoverable dropdown menu

I am trying to make a hoverable dropdown menu and the items of the dropdown are overlapped. I don't know how the CSS should be, but I tried to modify each class, but still doesn't work.
I also tried to modify the display of links, but that doesn't work. Here is the code I made:
<style>
#menu
{
margin:0;
font-size: 30px;
border-bottom: 1px solid;
text-align: center;
}
#menu a
{
color:#900;
text-decoration:none;
}
#menu .subitem a{
display: block;
padding: 12px 16px;
z-index: 1;
background-color: #f1f1f1;
border-bottom: 1px solid;
}
#menu a:hover
{
text-decoration:underline;
}
.item{
position: relative;
display: inline-block;
border-right: 0.5px solid;
padding-right: 30px;
padding-left: 30px;
}
.subitem{
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
left: 0;
z-index: 1;
}
#menu .item:hover .subitem{
display: block;
}
</style>
<div id="navWrapper">
<ul id="menu">
<li class="item">Small Things
<ul class="submenu">
<li class="subitem">Gnomes</li>
<li class="subitem">Fairies</li>
<li class="subitem">Elves</li>
<li class="subitem">Leprechauns</li>
</ul>
</li>
<li class="item">Big Things
<ul class="submenu">
<li class="subitem">Loch Ness Monster</li>
<li class="subitem">Ogres</li>
<li class="subitem">Giants</li>
<li class="subitem">Dragons</li>
</ul>
</li>
</ul>
</div>
I want to display properly each item when I hover with the mouse like it is in this
image.
You confused your .submenu with .subitem:
#menu
{
margin:0;
font-size: 30px;
border-bottom: 1px solid;
text-align: center;
}
#menu a
{
color:#900;
text-decoration:none;
}
#menu .subitem a{
display: block;
padding: 12px 16px;
z-index: 1;
background-color: #f1f1f1;
border-bottom: 1px solid;
}
#menu a:hover
{
text-decoration:underline;
}
.item{
position: relative;
display: inline-block;
border-right: 0.5px solid;
padding-right: 30px;
padding-left: 30px;
}
.subitem {
/* display: none; <- get rid of that */
/* position: absolute; <- get rid of that, otherwise all your subitems will be in the top left corner */
background-color: #f1f1f1;
min-width: 160px;
left: 0;
z-index: 1;
}
.submenu {
position: absolute; /* <- put it here */
display: none; /* <- put it here */
list-style-type: none;
left:-40px;
top: 30px;
}
#menu .item:hover .submenu {
display: block;
}
<div id="navWrapper">
<ul id="menu">
<li class="item">Small Things
<ul class="submenu">
<li class="subitem">Gnomes</li>
<li class="subitem">Fairies</li>
<li class="subitem">Elves</li>
<li class="subitem">Leprechauns</li>
</ul>
</li>
<li class="item">Big Things
<ul class="submenu">
<li class="subitem">Loch Ness Monster</li>
<li class="subitem">Ogres</li>
<li class="subitem">Giants</li>
<li class="subitem">Dragons</li>
</ul>
</li>
</ul>
</div>

My dropdown menu in my nav bar isn't aligning

I'm having trouble aligning my drop down menu in my nav bar, I've tried every suggestion out there. I've tried left, float: left, right, and pretty much everything else. I think it is possibly something interfering. The drop down menu has everything aligned from center to right of the parent menu item.
https://jsfiddle.net/ethacker/j7tgq95j/3/
My html code:
<header>
<nav>
<h1> Welcome to Mommy Madness</h1>
<ul>
<li class="parentMenu">Home
<ul class="sub-menu">
<li>About</li>
<li>Contact</li>
</ul>
</li>
<li class="parentMenu">Pregnancy
<!--
Gender Predictions:
Old Wive's Tale
Boy vs Girl- The Ramzi Method
-->
<ul class="sub-menu">
<li>Advice</li>
<li>Gender Predictions</li>
<li>Trying To Conceive</li>
</ul>
</li>
<li class="parentMenu">All About Baby
<ul class="sub-menu">
<li>Fetal Development</li>
<li>Guidelines </li>
<li> Milestones</li>
</ul>
</li>
<li class="parentMenu">Party Momma
<!--
Birthdays - Link to 1-10th bdays.
-->
<ul class="sub-menu">
<li>Pregnancy Announcement</li>
<li>Gender Reveal</li>
<li>Baby Shower</li>
<li>Birth Announcement</li>
<li> Birthdays</li>
</ul>
</li>
<li class="parentMenu">Stations
<ul class="sub-menu">
<li>Hospital Bag</li>
<li>Diaper Bag</li>
<li>Changing Station</li>
<li>Baby Gear</li>
</ul>
</li>
<li class="parentMenu">Memory Markers
<!--
Drop Down Menu:
DIY
Purchases
(Both to have holiday/event selectors on right of page)
-->
<ul class="sub-menu">
<li>DIY</li>
<li>Purchases</li>
</ul>
</li>
<li class="parentMenu">Reviews
<ul class="sub-menu">
<li>Games</li>
<li>Gear</li>
<li>Learning</li>
</ul>
</li>
<li class="parentMenu">Blog
<ul class="sub-menu">
<li>Fit Momma</li>
<li>Minimal Momma</li>
<li>Modern Momma</li>
<li>Organic Momma</li>
<li>Organizing Queen</li>
<li>Savings Savvy</li>
<li>Tech Savvy</li>
<li>Traditional Momma</li>
</ul>
</li>
</ul>
</nav>
My css code:
body {
background-color: beige;
color: lightblue;
padding: 0;
margin:0;
}
header {
background-color: lightblue;
padding: 5px 0;
margin: 0;
}
header h1 {
color: cadetblue;
font-family: Arial;
margin: 0;
padding: 5px 15px;
display: inline;
}
.navMenu{
display: inline;
margin: 0;
}
.navMenu .parentMenu {
display: inline-block;
list-style-type: none;
background-color: lightgray;
padding: 5px 10px;
border: thin solid darkgray;
border-radius: 3px;
color: honeydew;
position: relative;
margin: 0;
}
.navMenu .parentMenu a{
color: azure;
}
.navMenu .parentMenu .sub-menu{
display: none;
}
.navMenu .parentMenu:hover .sub-menu{
display: block;
position: absolute;
list-style-type: none;
margin:0;
}
.parentMenu:hover .sub-menu li{
border: thin solid darkgray;
padding: 4%;
background-color: lightgray;
color: honeydew;
text-align: left;
white-space: nowrap;
width: 100%;
list-style-type: none;
margin: 0;
}
.parentMenu .sub-menu li:hover {
background-color: lightsteelblue;
}
.section {
background-color: wheat;
color: darkslategray;
padding: 5px;
float: left;
display: inline;
width: 63%;
margin: 0 1% 1% 1%;
border-radius: 10px;
border: thin solid khaki;
box-shadow: lightgray;
}
#about {
float: right;
width: 30%;
margin: 1% 1% 0 0;
text-align: center;
}
#home{
margin: 1% 0 1% 1%;
}
h4, h3 {
color: lightseagreen;
}
This will align the submenu to the left:
.navMenu .parentMenu .sub-menu {
display: none;
position:absolute;
list-style-type: none;
padding:0;
margin: 0;
left:-1px;
top:27px;
}
.navMenu .parentMenu:hover .sub-menu {
display: block;
}
https://jsfiddle.net/am13qur4/
you did not specify where you want to align your drop down elements. Do you want to align all to the right, center or left. I assumed left so try adding the code below. You may need to adjust the left attribute's value and your hover background styling too.
.sub-menu a{
position: absolute;
left: 3%;
}
Let me know if this helps. Stay warm!

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;
}

CSS border bottom has missing corners

I would like to have a long border underneath my menu UL, but the "border-bottom" property on the list items does not work well:
#headermenu {
height: 40px;
background: #f47a20;
position: relative;
}
#headermenu .menu {
background: #F47B20;
float: left;
border: 1px solid #D66C1C;
padding: 0.6em 1em;
margin-top: 0.5em;
list-style-type: none;
}
#headermenu-left {
padding: 0;
position: absolute;
top: 0;
left: 0;
width: 70%;
margin: 0;
}
#headermenu-left .menu {
border-bottom: 4px solid #004B8D;
}
<body>
<div id="headermenu">
<ul id="headermenu-left">
<li class="menu">
Link 1
</li>
<li class="menu">
Link 2
</li>
<li class="menu">
Link 3
</li>
<li class="menu">
Link 4
</li>
<li class="menu">
Link 5
</li>
<li class="menu">
Link 6
</li>
</ul>
</div>
</body>
The border is interrupted at the corners by -I guess- the border-left and border-right properties not being there?
I can't put it on the <ul> element, because then the line runs too long.
You can put it on the UL if you get rid of the width on it. Remove your last rule and use this:
#headermenu {
height: 40px;
background: #f47a20;
position: relative;
}
#headermenu .menu {
background: #F47B20;
float: left;
border: 1px solid #D66C1C;
padding: 0.6em 1em;
margin-top: 0.5em;
list-style-type: none;
}
#headermenu-left {
padding: 0;
position: absolute;
top: 0;
left: 0;
margin: 0;
border-bottom: 4px solid #004B8D;
}
<body>
<div id="headermenu">
<ul id="headermenu-left">
<li class="menu">
Link 1
</li>
<li class="menu">
Link 2
</li>
<li class="menu">
Link 3
</li>
<li class="menu">
Link 4
</li>
<li class="menu">
Link 5
</li>
<li class="menu">
Link 6
</li>
</ul>
</div>
</body>
The problem, as you suggest, is the missing left and right borders, which have a width, but no color, so this distorts the appearance of the bottom border with the illusion of a missing notch.
To solve this you can simply define border-width: 0 for the element, and allow the border-bottom property to override that setting.
#headermenu {
height: 40px;
background: #f47a20;
position: relative;
}
#headermenu .menu {
background: #F47B20;
float: left;
border: 1px solid #D66C1C;
padding: 0.6em 1em;
margin-top: 0.5em;
list-style-type: none;
}
#headermenu-left {
padding: 0;
position: absolute;
top: 0;
left: 0;
width: 70%;
margin: 0;
}
#headermenu-left .menu {
border-width: 0;
border-bottom: 4px solid #004B8D;
}
<body>
<div id="headermenu">
<ul id="headermenu-left">
<li class="menu">
Link 1
</li>
<li class="menu">
Link 2
</li>
<li class="menu">
Link 3
</li>
<li class="menu">
Link 4
</li>
<li class="menu">
Link 5
</li>
<li class="menu">
Link 6
</li>
</ul>
</div>
</body>
Unfortunately this is how borders work. Those are the ends of your border-left, and border-right. Here's a work around though, I added a div to the bottom of your list:
(I also removed your width:70%; from your list)
#bluebar {
position:absolute;
bottom:0px;
width:100%;
height:5px;
background-color:blue;
}
http://jsfiddle.net/BjGvp/6/

Sidebar list is getting pushed to the right

I have a page that has a dark grey sidebar that has a ul in it that is holding some navigation. Currently the UL is getting pushed over within the side bar.
Fiddle: http://jsfiddle.net/PWZJd/
I would like the UL to be pressed up against the left side of the sidebar. Then I can add some padding to move it over as I see fit.
HTML:
<div class="content">
<header id="myNav" class="top_block navbar-fixed-top" >
<ul>
<li>Home</li>
<li>4Tell</li>
<li>Console 1</li>
<li>Console 2</li>
<li>About</li>
</ul>
</header>
<aside class="background sidebar">
<div class="sidenav">
<ul class="menu side-menu">
<li>NCR at your service</li>
<ul class="sub-menu">
<li>My Support Link</li>
<li>My Asset List</li>
<li>My Invoices</li>
<li>My Somthing Else</li>
</ul>
<li>Q2C MAC</li>
<ul class="sub-menu">
<li>Move</li>
<li>Add</li>
<li>Change</li>
<li>Swap</li>
</ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</aside>
<div class="left_block sidebar">
</div>
<div class="bottom_block footer">
<p class="text-center">Designed by Steve Wilson <br>With contributions from Alex Cronon and Robert Moua</p>
</div>
</div>
CSS:
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.content {
min-height: 100%;
position: relative;
overflow: auto;
z-index: 0;
}
.background {
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
margin: 0;
padding: 0;
}
.top_block {
width: 100%;
display: block;
}
.bottom_block {
position: absolute;
width: 100%;
display: block;
bottom: 0;
}
.left_block {
display: block;
float: left;
}
.right_block {
display: block;
float: right;
}
.center_block {
display: block;
width: auto;
}
.background.sidebar {
height: auto !important;
padding-bottom: 0;
left: 0;
width: 200px;
background-color: #33404c;
margin-top: 50px;
margin-bottom: 50px;
border-right: 1px solid;
}
.sidebar {
height: auto;
width: 20%;
padding-bottom: 75px;
}
.footer {
width: 100%;
height: 50px;
background-color: #e3e6ea;
padding-top: 5px;
}
.sidenav {
margin-top: 10px;
color: #f9fafb;
}
.side-menu {
font-size: 1.2em;
font-family: 'Open Sans', sans-serif;
list-style: none;
line-height: 2em;
}
*Note: I have cut some of the code for Stack Overflow, see the fiddle for a more complete version.
adjust the padding and margin on your side-menu to 0.
See: http://jsfiddle.net/PWZJd/2/
The default padding on the ul element is what's moving it to the right. Just update the padding and you can dock the ul up against the left side of the side-bar as close as you want.
Demo: http://jsfiddle.net/PWZJd/3/