Skip to content

Instantly share code, notes, and snippets.

@okuden-labo
Last active December 19, 2017 02:16
Show Gist options
  • Save okuden-labo/1449195736f6cbf95b6cdb047628c1fa to your computer and use it in GitHub Desktop.
Save okuden-labo/1449195736f6cbf95b6cdb047628c1fa to your computer and use it in GitHub Desktop.
:target疑似クラスを使って、コンテンツを表示・非表示することで、簡易版の開閉パネルを作成。 参考サイト:http://coliss.com/articles/build-websites/operation/css/target-pseudo-class-trick.html
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>:target疑似クラスを使って、コンテンツを表示・非表示</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
#comments {
padding-top: 70px;
}
#comments:not(:target) {
display: none;
}
#comments:target {
display: block;
}
</style>
</head>
<body>
<div class="wrapper body-wrapper">
<h1>簡易版の開閉パネル</h1>
<p>:target疑似クラスを使って、コンテンツを表示・非表示することで、簡易版の開閉パネルになる</p>
<a href="#comments">Show Comments</a>
<section id="comments">
<h3>Comments</h3>
<p>ここは隠れている部分のコンテンツです。</p>
<a href="#">Hide Comments</a>
</section>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment