I have a number of tables that have many rows. I want to initially only show the first three table rows. When a user clicks the Show/Hide link, then all hidden rows will be toggled. I have achieved this so far with CSS3 and JavaScript (see Fiddle).
CSS (only show three rows by default):
.hide tr:nth-child(n+4) {
display:none;
}
JavaScript (toggle above class to show all rows):
function ShowHide() {
var tables = document.getElementsByClassName('foo');
for(i=0; i<tables.length; i++) {
tables[i].classList.toggle("hide");
}
}
Is it possible to use the transition
functionality of CSS3 to make the rows appear slowly, rather than instantly? For example, fade in/out over 2 seconds?
I know this can be done easily in JQuery, but I'm looking for a pure CSS solution.