![]() |
Making a <div> disappear
Hello,
I'm quite new to webdesign. I've got a basic knowledge about HTML and CSS, but none whatsoever regarding JS or any other coding language. I'm right now trying to get something done, which I think is incredibly simple, but I cannot seem to find a way to do it. I have got two DIVs, one (top1) exactly on top of the other (bot1). What I want, is to make the top one disappear when someone clicks on the DIV. I don't even want it to reappear, it just has to disappear once when it's clicked. After some internet research, I think it could be done with a tiny bit of script, but I cannot seem to get it right. Or is there maybe even a more simple way to solve this? Here is the complete code of my page: Code:
<html>Code:
body{ I hope someone can help me out, it would be really appreciated. Thank you in advance! |
Any time you want to change your page 9 out of ten times it's done with javascript. Advise you to start studying. Js is used below
Code:
<body> |
Sunfighter, didn't I see a post here where this was done via CSS alone? The half hour search didn't find it, but I'm pretty sure it was here.
|
ah sunfighter, that worked perfectly, and indeed, it was just such a small bit of code. i'll definitely start learning js!
also, i have found traces of such thing being possible in css only, but i couldn't make it work myself. obviously that does not mean it's impossible, so if someone knows that would definitely be interesting as well. thanks a lot for your fast help! |
"A css solution"(?) Every time I say yes or no absolutely someone comes along and shows that it's possible. You can use the hover feature of css to do this temporarily, but I don't think that can be changed to a permanent thing.
css could do this with the :target feature< but we have to change the html and add to the css; Added to css: Code:
div #top1:target {Code:
<body>BUT now we use z-index. So to the #bot1 css mark up we add: Code:
z-index: 5;To the css :target we CHANGE it to: Code:
div #top1:target {And we change this: Code:
<div id="bot1">Bottom</div>The total comes out: Code:
#bot1 {Thanks for making do some research. But the javascript is the fastest way and only 2% of users have it turned off and the heck with them. They're probably paranoid and don't care if they see the whole web. Code:
div #top1:target { |
very interesting!
|
| All times are GMT +1. The time now is 09:46 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.