The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other A way to make css register clicks!

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #29751

    A way to make css register clicks! demo:
    this isn’t exactly a replacement for javascript’s onclick event ($().click(function() {});) but it works if you want something to happen to an element when it’s clicked and for it to revert back when something else is clicked, like a lightbox or dropdown menu.

    The trick is to use the css :focus pseudo-class to detect clicks. Normally this only works with form elements, but html5 gives us the contenteditable attribute which lets any element be "focused". Just hide the outline on the when the element is focused and apply the effect.

Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.