Yes, but you probably would want some javascript anyway.
#show {
padding: 20px;
background: #ccc;
max-height:0;
overflow:hidden;
-webkit-transition:max-height 1s;
-moz-transition:max-height 1s;
transition:max-height 1s;
}
#show:target {
max-height:1000px; /* you can't transistion to height:auto */
}
http://jsfiddle.net/richbradshaw/hgdrw/1/
There are a few things here:
- the :target selector
- The page will jump to the ID if you don't use JS to cancel that behaviour
- The only way to close it is to change the URL so it doesn't include #show at the end
If I were doing this, I would use what I have here, but instead of the target selector, I'd add a class to #show called 'active' using JS, and change #show:target
to #show.active
.
http://jsfiddle.net/richbradshaw/hgdrw/2/
I'm using jQuery here because it's so simple,
The target selector isn't really great for use in practice in my experience.