ANGULARJS switch site color scheme Simple example

Source: Internet
Author: User

A website can have multiple color schemes, such as normal mode, night mode, and so on.

A simple example is a ANGULARJS small app that switches the color scheme by clicking the button and replacing the CSS file.

The main files are three: index.html (master file), white.css (white background color scheme css file), BLACK.CSS (black background color scheme css file).

The index.html file code is as follows:

<! DOCTYPE html>


The black.css code is as follows:

Body{background-color:black;}. p1{color:red;}. P2{color:blue;}

The white.css code is as follows:

Body{background-color:white;}


Index.html uses a black background color scheme by default. Click on the "White theme" button to switch to the black background color scheme, click "Black Theme" button to switch to a dark background color scheme. Specific examples are as follows:

Run index.html in the browser as follows:


To view the Web page source code, you can see that the called CSS file is black.css:


Click on the "White theme" button and change the index.html to a color scheme with the following page:


To view the Web page source code, you can see that the called CSS file is white.css:



ANGULARJS switch site color scheme Simple example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.