Skip to content

Instantly share code, notes, and snippets.

@kgtkr
Created May 14, 2017 03:57
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 kgtkr/84b91ab5ccf717606e3a7e78e77ab4a8 to your computer and use it in GitHub Desktop.
Save kgtkr/84b91ab5ccf717606e3a7e78e77ab4a8 to your computer and use it in GitHub Desktop.
body{
font-size:var(--font-size,16px);
}
function setFontSize(size){
localStorage.setItem('font-size',size);
document.body.style.setProperty(size);
}
$(()=>{
let size=localStorage.getItem('font-size');
if(size){
setFontSize(size);
}
});
$('#font-min').on('click',()=>setFontSize('12px'));
$('#font-normal').on('click',()=>setFontSize('16px'));
$('#font-big').on('click',()=>setFontSize('20px'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment