Created
May 11, 2020 15:59
-
-
Save mmcguff/afad1089fa79a238cdc00b5271e623df to your computer and use it in GitHub Desktop.
This Gist will demonstrate a simple of way o toggling between different style sheets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: blue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: green; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link id="pagestyle" rel="stylesheet" type="text/css" href="default.css"> | |
<title>css example</title> | |
<!-- Placing the logic for style swapping in the head of my html so its be available for toggling style --> | |
<script> | |
function swapStyle(sheet) { | |
document.getElementById('pagestyle').setAttribute('href', sheet); | |
} | |
</script> | |
</head> | |
<body> | |
<h1>CSS Example Style Sheet</h1> | |
<button onclick="swapStyle('blue.css')">Blue</button> | |
<button onclick="swapStyle('red.css')">Red</button> | |
<button onclick="swapStyle('default.css')">Green</button> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment