Automatically switch the CSS style of the website according to the time period

Source: Internet
Author: User

The site can switch a few sets of CSS style has not been a novelty. We all know how to get it. This article describes the same switching style. But a little adjustment was made. The site will automatically adjust the site style based on the time of day. The author for the site produced in the morning, afternoon, night three sets of skin, mainly produced a background. 12 before the system will use the morning skin, after 12 points, the site will automatically replace the style of the afternoon, 5 points after the replacement of the style of the night.

The main function of the implementation is to rely on the head of this section of the judgment code, it is easy to understand. Be interested to try it on your own.

<link rel= "stylesheet" type= "Text/css"
href= "<?php $hour = Date (" H "); if ($hour <) echo "MORNING.CSS"; ElseIf ($hour <) echo "DAY.CSS"; else echo "Night.css";?>
"/>


ASP version code is as follows:

<link rel= "stylesheet" type= text/css "href=" <%
If hour (now) <12 then
Response.Write "A.css"
Else
If hour (now) <17 then
Response.Write "B.css"
Else
Response.Write "C.css"
End If
End If
%> "/>

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.