Skip to content

Instantly share code, notes, and snippets.

@nahakyuu
Created June 27, 2016 09:44
Show Gist options
  • Save nahakyuu/bfb046ee083045cf98873a662d14141c to your computer and use it in GitHub Desktop.
Save nahakyuu/bfb046ee083045cf98873a662d14141c to your computer and use it in GitHub Desktop.
显示全部
<!DOCTYPE html>
<html lang="zh-hans">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#main {
border: 1px solid #000;
width: 200px;
}
.show::after {
content: "显示全部";
font-weight: bold;
}
.hide::after {
content: "隐藏";
font-weight: bold;
}
.show > .body {
line-height: 1.4em;
height: 7em;
overflow: hidden;
}
</style>
</head>
<body>
<div class="show" id="main">
<div class="body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa sed nobis recusandae officia error alias iste nisi eveniet,
molestias quo beatae amet totam quibusdam delectus debitis voluptas nesciunt reiciendis eligendi. Fuga accusamus,
laborum id.
</div>
</div>
<script>
var main = document.getElementById('main');
main.onclick = function () {
main.classList.toggle('show');
main.classList.toggle('hide');
}
</script>
</body>
</html>
@nahakyuu
Copy link
Author

nahakyuu commented Aug 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment