Skip to content

Instantly share code, notes, and snippets.

@michaelcullum
Created February 13, 2012 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelcullum/1817534 to your computer and use it in GitHub Desktop.
Save michaelcullum/1817534 to your computer and use it in GitHub Desktop.
Basic FAQ
<!doctype html>
<html>
<head>
<title>FAQ</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<dl>
<dt>Q1</dt>
<dd>Answer 1</dd>
<dt>Q2</dt>
<dd>Answer 2</dd>
<dt>Q3</dt>
<dd>Answer 3</dd>
<dt>Q4</dt>
<dd>Answer 4</dd>
<dt>Q5</dt>
<dd>Answer 5</dd>
</dl>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
(function() {
var dd = $('dd')
dd.filter(':nth-child(n+4)').addClass('hide');
$('dt').on('mouseenter', function() {
$(this)
.slideDown(200)
.show()
.siblings('dd')
.slideUp(200);
})
})();
</script>
</body>
</html>
body {
width: 500px;
margin: auto;
text-align: center;
}
dl {
}
dd {
margin: 0;
padding: 1em 0;
}
dt {
cursor: pointer;
font-weight: bold;
font-size: 1.5em;
line-height: 2em;
background: #e3e3e3;
border-bottom: 1px solid #c5c5c5;
border-top: 1px solid white;
}
dt:first-child {
border-top: none;
}
dt:nth-last-child(2){
border-bottom: none;
}
.hide {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment