Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

How do I add vertical lines between navigation labels ?

Community Beginner ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

This is prob a very simple solution, however I never done it before, How would I be able to add Vertical lines between navigation labels. I tried to use Photoshop and save a line to a png but I'm sure there is a proper way to this solution. As always help would be appreciated.


Home|About|Contact| 

TOPICS
How to

Views

17.0K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

Use CSS border-right property.

nav ul {

    margin: 0;

    padding: 0

}

nav li {

    list-style: none;

    font-size: 12px;

    float: left;

    text-align: center;

}

nav li a {

    display: block;

    text-decoration: none;

    margin-right: 0;   /* space between links */

    width: auto;   /* adjust width as needed or use auto */

    padding: 6px;

    font-weight: bold;

    line-height: 2em;

    color:#1e5799;

    border-right: 1px solid #000;

}

/**remove from last item**/

nav li:last-child a {

    border:none;

}

/**float clearing**/

nav:after {

     content: '';

     clear:left;

     display:block;

}

HTML:

<nav>

     <ul>

          <li><a href="index.html">Home</a></li>

          <li><a href="about.html">About</a></li>

          <li><a href="contact.html">Contact</a></li>

     </ul>

</nav>

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

I want the vertical line to go from top to bottom of the blue navigation bar

theline.png

This is my CSS code

.Fbicon{

  background:url(../images/fbicon.png);

  width: 24px;

  height: 24px;

  float: right;

  margin-top:17px;

  border-right: 1px solid #fff;

}

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

The css for the icon is based on the dimensions of the icon. You could make a separate "|" to match the size of the nav  and position it after the fb icon.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

Height of border is determined by the font-size and padding on your list anchors - nav li a.

Try pasting this code into a new, blank document.

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

<style>

body {

    margin:0;

    padding:0;

}

nav {

    background: navy;

    width: 100%;

    margin:0;

    padding:0

    }

nav ul {

    margin: 0;

    padding: 0;

}

nav li {

    list-style: none;

    font-size: 14px;

    float: left;

    text-align: center;

}

nav li a {

    display: block;

    text-decoration: none;

    margin-right: 0;   /* space between links */

    width: auto;   /* adjust width as needed or use auto */

    padding: 6px;

    font-weight: bold;

    line-height: 2em;

    color: #FFF;

    border-right: 1px solid #FFF;

}

/**remove from last item**/

nav li:last-child a { border: none; }

/**float clearing**/

nav:after {

    content: '';

    clear: left;

    display: block;

}

/**on focus**/

nav li a:hover,

nav li a:active,

nav li a:focus {text-decoration:underline}

/**facebook**/

.fbicon {

        float:right;

        width:24px;

        margin-top:17px;

}

</style>

</head>

<body>

<nav>

<ul>

<li><a href="index.html">Home</a></li>

<li><a href="about.html">About</a></li>

<li><a href="contact.html">Contact</a></li>

</ul>

<img class="fbicon" src="images/fbicon.png">

</nav>

</body>

</html>

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

I'm doing it between the icons though , not the links.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

raiden92 wrote:

I'm doing it between the icons though , not the links.

That's not what you said in your first post.  You said


Home|About|Contact| 

Which is what my CSS & HTML code provides for.

If you want to put Pipes between icons, use special HTML entities.

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

LATEST

Oh yeah, that's my bad. I just realized that.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

Or simply type the uppercase "pipe" keystroke between your links

backslash-key-pc.jpg

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2014 Nov 30, 2014

Copy link to clipboard

Copied

I do not know if this is what you are asking but if you wish to add the vertical "|" in a HTML document simply use &#124 this will display the vertical pipe  that you wish to use. For a list of special characters here is a good resource for you

HTML Codes - Table of ascii characters and symbols

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines