Can :hover e set to :click in CSS?

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can :hover e set to :click in CSS?

Post by simonmlewis »

Code: Select all

.admin_listproducts ul li:hover ul {
  display: block;
  opacity: 1;
  visibility: visible;
width: 130px;
  z-index: 2;
-webkit-box-shadow: 0px 5px 5px -7px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 10px 5px -7px rgba(0,0,0,0.75);
box-shadow: 0px 7px 5px -5px rgba(0,0,0,0.75);
}
I have this part of a CSS Class. It makes a menu popup when hovering over the DIV. But it wont' work for mobile.

So can it be altered so it works on Click instead? the DIV appears over the top of other stuff.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Christopher
Site Administrator
Posts: 13595
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Can :hover e set to :click in CSS?

Post by Christopher »

Using Javscript would be the easiest. Have you tried using :focus or :active in addtion to :hover?
(#10850)
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can :hover e set to :click in CSS?

Post by simonmlewis »

Active wont' work as it only makes it popup when the click is 'down'. So rubbish for mobile friendly.
Would focus work then??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Can :hover e set to :click in CSS?

Post by Celauran »

simonmlewis wrote:Active wont' work as it only makes it popup when the click is 'down'. So rubbish for mobile friendly.
I'm not sure I see the problem here. They click the target element, menu pops up. That's pretty standard.
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can :hover e set to :click in CSS?

Post by simonmlewis »

Really? So if you want a click on it to make the menu popup... how are you meant to click the links n the menu, if when you "unclick" the mouse, the menu disappears as it's no longer "active"?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Can :hover e set to :click in CSS?

Post by Celauran »

Yeah, I was thinking JS .click rather than CSS :active. My mistake.
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can :hover e set to :click in CSS?

Post by simonmlewis »

So I don't know how to do that.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply