How to make changeable themes using CSS and JavaScript

后端 未结 6 1075
礼貌的吻别
礼貌的吻别 2020-11-28 22:42

I\'m pretty new to CSS and JavaScript and I was wondering if you could make a script that allows you to change what stylesheet the site uses.

Say: you had a green t

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 23:35

    You don't even need any Javascript:

    input[type=radio][value=light]:checked ~ article {
        color: #222;
        background-color: #FFEEAA;
    }
    
    input[type=radio][value=dark]:checked ~ article {
        color: #EEE;
        background-color: grey;
    }
    
      Light
    Dark

    My super page!

    Quibusdam sit repudiandae consequuntur doloremque illum ut ex quo. Esse temporibus est id suscipit repellat. Distinctio voluptatem voluptates asperiores dolorem dolorem placeat corporis quae. Quaerat voluptatem magni dignissimos rerum distinctio odio id.

提交回复
热议问题