Arrow in menu with CSS and apparent when clicked

Asked

Viewed 504 times

-2

I’m trying to do almost the same as what was described in this other question: Arrow in menu with CSS only.

But with one small difference: when you click the button that is marked as selected. Show that she’s on that page, but along with the highlighted arrow.


And like this now, and I want you to stay in this other image, that the arrow is in the middle, and I can’t do that.

Code

nav a{ 
    text-decoration: none; 
    padding: 8px 8px 8px 8px; 
    color: #ffffff; 
    position: relative;
} 

nav a:hover:before{ 
    width: 0; 
    height: 0; 
    border: 10px solid transparent; 
    border-top-color: #888888; 
    content: ""; 
    bottom: -20px; 
    position: absolute; 
}
  • You did the MENU, now all that remains is to show the arrow when you are on the page of that Link in the MENU ?

  • That, but I can’t

  • wanted to make the arrow stand out when you were on a page

  • What is the code of the arrow ? Put it there.

1 answer

1

First, you have to have a CSS like this:

.dropdown.current {
    width: 0;
    height: 0;
    position: absolute;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid red;
    bottom: -10px;
    left: 20%;
}

Then in each line of the LINK you put in tag of class="dropdown" one if to check if you are on this page, if yes you apply to class='current'.

You are using some server-side, PHP-like language, or just HTML, CSS and JS ?

The if can be done in a JS or PHP code.


In his CSS below put the properties:

left: 0; 
right: 0;
margin: auto;

Thus:

nav a:hover:before{ 
    width: 0; 
    height: 0; 
    border: 10px solid transparent; 
    border-top-color: #888888; 
    content: ""; 
    bottom: -20px; 
    position: absolute; 
    left: 0; 
    right: 0;
    margin: auto;
}
  • Just HTML and CSS, I’m not using anything else.

  • is a lot, and already everything on the site that I’m doing

  • and I have to leave

  • now don’t, I’ll do it when I arrive

  • 1

    thanks for the help

  • 1

    you got one that’s the way I want it?

  • 1

    I got it fixed, thanks for your help.

  • 1

    Just one more question how do I center this ARROW in a rectangle or square?

  • I don’t quite understand, you can explain better?

  • I’m looking for you. 
nav a{
 text-decoration: none;
 padding: 8px 8px 8px 8px;
 color: #ffffff;
 position: relative;
}

nav a:hover:before{
 width: 0;
 height: 0;
 border: 10px solid transparent;
 border-top-color: #888888;
 content: "";
 bottom: -20px;
 position: absolute;
}

  • I don’t know how to put code here

  • No problem, I edited my post. See now.

  • 2

    Now it’s gone, thank you very much

Show 8 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.