Jump to content

How to place separator in css


newcoder1010

Recommended Posts

The content property only works with :before and :after selectors.

 

So you would do it like this:

navbar-default .navbar-nav>li>a:after {    content: " | ";}

You can change its color, font and all the rest with other CSS properties in the same selector.

Link to comment
Share on other sites

.navbar-default .navbar-nav>li>a:after  {   /* color: #777;*/       color: #8B0000;    background-color: white;    font-weight:bold;    padding: 0 10px;    float:left;    border-style: solid;    border-width: 1px;    content: " | ";}

I did place your code with other CSS and the main menu links don't look right. I simple like to place the separator after each link except the last link.

 

http://realestatesdcmetroareas.com/

 

Thanks.

Link to comment
Share on other sites

.navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav > .active>a:hover, .navbar-default .navbar-nav>.active>a:focus {   /* color: #555;    background-color: #e7e7e7;*/    color: white;    background-color: #8B0000;    font-weight:bold;}

I made some progress. If you visit my page, you will notice that when a link is active, I see the background color is under link name and the separator. How to put the background color under link name only and how to remove the last separator?

Link to comment
Share on other sites

The :after selector creates a pseudo-element that acts as if it was inside the element it belongs to. If you don't want that you'll have to actually add the content to the page's HTML instead of using the :after selector

 

You can use the :last-child selector to make the last link not have the vertical bar.

.navbar-default .navbar-nav>li>a:last-child:after {  content: "";}
Link to comment
Share on other sites

.navbar-default .navbar-nav>li>a  {    color: #8B0000;    font-weight:bold;    padding: 0 10px;    float:left;    border-style: solid;    border-width: 0px;    margin-right:10px;}.navbar-default .navbar-nav>li>a:after  {margin:10px;    content: " | ";}.navbar-default .navbar-nav>li>a:last-child:after {  content: "";}

When I added the css, all the vertical bars are gone.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...