Skip to content

Instantly share code, notes, and snippets.

@amane-katagiri
Created March 9, 2021 08:23
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 amane-katagiri/d52284d464386bdfdac8be109c5d4534 to your computer and use it in GitHub Desktop.
Save amane-katagiri/d52284d464386bdfdac8be109c5d4534 to your computer and use it in GitHub Desktop.
チェックボックスでスタイルを切り替える
<html>
<head>
<title>チェックボックスでスタイルを切り替える</title>
<style>
#main {
background-color: red;
}
input[type="checkbox"]#toggle:checked ~ #main {
color: #eee;
background-color: blue;
}
</style>
</head>
<body>
<input id="toggle" type="checkbox">
<section id="main">
<div>チェックボックスでスタイルを切り替える</div>
</section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment