HighDots Forums  

Set block element display:none on click

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Set block element display:none on click in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
VK
 
Posts: n/a

Default Set block element display:none on click - 11-02-2006 , 07:38 PM






Hi,

given a block element with some content and a link, is it possible to
set this element display to none by CSS only? It has to be done only
once. It is an absolutely positionned element so visibility:hidden will
do as well.

<div>
<p>Some content</p>
<p><a href="#">Hide</a></p>
</div>


Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Set block element display:none on click - 11-02-2006 , 11:58 PM






Scripsit VK:

Quote:
given a block element with some content and a link, is it possible to
set this element display to none by CSS only?
Of course. You just set display: none for the element.

The correct answer to the question you ask in the Subject line is "No."
There is no CSS selector related to clicking. (It's a bad idea to imply
anything from the Subject line in the message body, and particularly bad to
ask a similar-looking but quite different question.)

Quote:
It has to be done only once.
Huh? This relates to clicking, right? The answer is even more "No."

Quote:
It is an absolutely positionned element so visibility:hidden
will do as well.
This doesn't matter, since the problem is not with properties but with the
impossibility of "capturing" the click in CSS terms.

Quote:
div
p>Some content</p
p><a href="#">Hide</a></p
/div
You do realize, don't you, that in HTML terms the link points to the start
of the current document, instead of being a no-op.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #3  
Old   
Ben C
 
Posts: n/a

Default Re: Set block element display:none on click - 11-03-2006 , 03:37 AM



On 2006-11-03, Jukka K. Korpela <jkorpela (AT) cs (DOT) tut.fi> wrote:
Quote:
Scripsit VK:

given a block element with some content and a link, is it possible to
set this element display to none by CSS only?

Of course. You just set display: none for the element.

The correct answer to the question you ask in the Subject line is "No."
There is no CSS selector related to clicking.
There are the :active and :focus pseudoselectors, but I doubt they can
actually be used to achieve what the OP wants.


Reply With Quote
  #4  
Old   
JP. Baker
 
Posts: n/a

Default Re: Set block element display:none on click - 11-03-2006 , 10:15 AM



In article <1162514285.830855.198110 (AT) b28g2000cwb (DOT) googlegroups.com>,
VK <schools_ring (AT) yahoo (DOT) com> wrote:
Quote:
Hi,

given a block element with some content and a link, is it possible to
set this element display to none by CSS only? It has to be done only
once. It is an absolutely positionned element so visibility:hidden will
do as well.

div
p>Some content</p
p><a href="#">Hide</a></p
/div

You probably be able to do it eventually with CSS3 selectors:

<style type="text/css">
p#note:target {display: none}
</style>

ASDFG
<p id="note"><a href="#note">Hide</a></p>
ZXCVB

This works in Firefox 2.
--
John P Baker


Reply With Quote
  #5  
Old   
VK
 
Posts: n/a

Default Re: Set block element display:none on click - 11-03-2006 , 10:45 AM



Quote:
You probably be able to do it eventually with CSS3 selectors:

<style type="text/css"
p#note:target {display: none}
</style

ASDFG
<p id="note"><a href="#note">Hide</a></p
ZXCVB

This works in Firefox 2.
Thank for the tip, I'll keep it. For with the current support for CSS3
extra selectors I better stay I guess with the overloaded A element.
A year or two later things will get much easier I guess... :-)



Reply With Quote
  #6  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Set block element display:none on click - 11-03-2006 , 02:02 PM



Scripsit VK:

Quote:
The correct answer to the question you ask in the Subject line is
"No." There is no CSS selector related to clicking.

a:hover a:active a:visited ?
What makes you think any of them relates to clicking?

If you actually _meant_ hovering or activation (whatever that means - the
specs don't say) or having been visited, why did you write about clicking?

Quote:
p><a href="#">Hide</a></p
/div

You do realize, don't you, that in HTML terms the link points to the
start of the current document, instead of being a no-op.

Moreover, I even know that these funny words in brackets are called
T-A-G's and you do stuff with them in ... that's the difficult one...
H-T-M-L
Your willingness to look amusing seems to exceed your willingness to learn
the basics of HTML. You are _still_ using href="#" in your code snippet,
apparently without ever considering what happens when the link is actually
used the way links are meant to be used. By clicking on it, for example.
Perhaps in a non-CSS browsing situation.

Quote:
Anyway, I needed a warning in <noscript> user could remove from the
screen but only after having read it.
That's simply pointless. Either you make your page work with scripting
disabled, or you don't. In rare cases, you might have reasons to explain
_what_ the user is actually missing when scripting is off, but what you seem
to work with is worse than useless technobabble and irritation:

Quote:
span>Client-side scripting is disabled.<br
Some extended features of this page will
be not available.</span><br
(BTW, your technique does not work on IE 7, for example, even for your
definition of "work". I guess I know why, but I don't know why I would
bother.)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #7  
Old   
VK
 
Posts: n/a

Default Re: Set block element display:none on click - 11-03-2006 , 03:35 PM



Quote:
a:hover a:active a:visited ?

What makes you think any of them relates to clicking?

If you actually _meant_ hovering or activation (whatever that means - the
specs don't say) or having been visited, why did you write about clicking?
Boring to anser

Quote:
You do realize, don't you, that in HTML terms the link points to the
start of the current document, instead of being a no-op.

Moreover, I even know that these funny words in brackets are called
T-A-G's and you do stuff with them in ... that's the difficult one...
H-T-M-L

Your willingness to look amusing seems to exceed your willingness to learn
the basics of HTML. You are _still_ using href="#" in your code snippet,
apparently without ever considering what happens when the link is actually
used the way links are meant to be used. By clicking on it, for example.
You desire to be boring and irritating seems exceed sometimes your
ability to be helpful. Anyone who programmed for NN2, NN3/IE3 knows
about # anchor and the "scroll to top" effect caused by it at that time
in pseudo links. That is why I was smiling: because it's like
explaining what a hammer is to a carpenter.

In my case I'm using # anchor exacly because of its function.

Quote:
That's simply pointless. Either you make your page work with scripting
disabled, or you don't. In rare cases, you might have reasons to explain
_what_ the user is actually missing when scripting is off, but what you seem
to work with is worse than useless technobabble and irritation:
I'm on the other side of the pond you're sitting in.



Reply With Quote
  #8  
Old   
Eric B. Bednarz
 
Posts: n/a

Default Re: Set block element display:none on click - 11-03-2006 , 08:40 PM



"VK" <schools_ring (AT) yahoo (DOT) com> writes:

Quote:
Moreover, I even know that these funny words in brackets are called
T-A-G's
… generic identifiers and attribute specifications (just to rescue the
orphaned possessive case) …

Quote:
and you do stuff with them in ...
As far as tags are concerned, one describes stuff with them (hence
‘descriptive markup’, as opposed to processing instructions).

Quote:
that's the difficult one...
H-T-M-L
As you can see I'm rather well prepared, but still thank you for taking
your time to explain.
;-)
I sense an upcoming explanation of ‘the basics’ for the rest of us.


--
Quote:
|| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.