Skip to content

Instantly share code, notes, and snippets.

@AnmolPlayzz
Created January 30, 2023 18:15
Show Gist options
  • Select an option

  • Save AnmolPlayzz/8abb3698decfbb04e7a84b98d0439efe to your computer and use it in GitHub Desktop.

Select an option

Save AnmolPlayzz/8abb3698decfbb04e7a84b98d0439efe to your computer and use it in GitHub Desktop.
LilWebsite
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Website</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.2.0/styles/default.min.css" />
<style>
body {
font-family: sans-serif;
background-color: #fff;
color: #333;
padding: 1em;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1em;
}
h1 {
font-size: 2em;
margin: 0;
}
#toggle-dark-mode {
float: right;
background-color: #333;
color: #fff;
border: none;
border-radius: 5px;
padding: 0.5em 1em;
cursor: pointer;
outline: none;
}
.code-block {
background-color: #f5f5f5;
padding: 10px;
border-radius: 5px;
}
.dark-mode {
background-color: #333;
color: #fff;
}
.dark-mode pre {
background-color: #444;
color: #ddd;
}
.dark-mode .code-block {
filter: invert(1)
}
</style>
</head>
<body>
<header>
<h1>All term 2 programmes</h1>
<button id="toggle-dark-mode">Dark Mode</button>
</header>
<main>
<p>and I know I shouldn't be making this for ... you know.</p>
<pre><code class="code-block language-python">print("Hello world!")
</code></pre>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.2.0/highlight.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
const codeBlocks = document.querySelectorAll("pre code");
codeBlocks.forEach((codeBlock) => {
hljs.highlightBlock(codeBlock);
});
const toggleButton = document.querySelector("#toggle-dark-mode");
const body = document.querySelector("body");
toggleButton.addEventListener("click", () => {
body.classList.toggle("dark-mode");
});
</script>
</body>
</html>
@AnmolPlayzz
Copy link
Author

you won't question me why

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