0

I have a top horizontal menu on my website, where I have some links. I would like to use the buttons to redirect the reader to sections on my sidebar, where there are sections with more detailed options. In order to ease location of the desired content, I would like that, by clicking on a button on the top menu, besides moving the screen to the desired section (which I get by using simple HTML: <a href="#section1">Section 1</a>), that the section flashed in yellow once (once for each time the user clicks the link).

Is this possible to get by using only CSS?

  • I'm not aware of being able to do this with just CSS. I think it would involved adding a style element that fades on click, which would require JS. – rguttersohn Aug 18 '20 at 19:10
  • @rguttersohn [This question](https://stackoverflow.com/questions/16344354/how-to-make-blinking-flashing-text-with-css-3) here on StackOverflow has a code for CSS Animation that makes text blinks infinitely. Well, removing "infinite" makes it blink once. If it's possible to blink, it should not be hard to make it flash the background onclick, right? So, what makes it impossible? Is it that the section to flash is another one? – Rezando Casto Aug 18 '20 at 19:30
  • It's the triggering of the animation on click that requires Javascript. You'd have to write a function that would first remove the class with the animation and then immediately add it back, so that it animates once each time the element is clicked. – rguttersohn Aug 18 '20 at 19:34
  • @rguttersohn Oh, fine. I remember learning something about onlick, but it really was on JavaScript then, not on CSS. Thank you, anyway. – Rezando Casto Aug 18 '20 at 19:38

1 Answers1

0

You need JS .onclick and the question need edit to js not only css!