I want to do a menu for my website like this with the transition in each section. I want the red bar move along I click on other sections.
What is the best way to do that?
I have also tried to do it myself but it doesn’t work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you want to achieve the same effect using just CSS3? That menu uses JavaScript. There is no CSS way (yet… it should come with CSS4) to change the CSS of an element by clicking an element that isn’t its sibling or it’s parent.
It is possible, however, to achieve the same effect for the bar (for smooth scrolling you need to use JavaScript). But not with that HTML structure.
I’ve tried a couple of things:
1. This http://dabblet.com/gist/3155730 does it with links, but whenever you click elsewhere on the page (not on the links) the effect disappears.
The idea in this case is to have a gradient on that element below and to change its size when clicking the links. Do note that the HTML is different, so that the element below can be a sibling of the links.
The formatting of the HTML does serve a purpose: I’ve made the links
inline-blockso I cannot have any kind of white space between the closing tag</a>and the next opening tag<a class="goto-frame">.The CSS:
Works in Chrome, Firefox, Safari, Opera, IE10 as gradients don’t work in IE9 and older (and neither do transitions).
Could be made to work in IE9 and 8 and older by using a pseudo-element on
.ui-menu-bottom-line, setting itsbackgrounddark red and then changing itswidthon click (instead of changing the background gradient size).2. This http://dabblet.com/gist/3155740 works as required even after releasing the mouse button, but it does not use links.
HTML
CSS – same idea, only this time I’m not clicking links – I’m checking radio buttons instead