Results 1 to 2 of 2

Thread: CSS weekday colour change

  1. #1
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default CSS weekday colour change

    Hi,

    I'm stuck with a css calander i am making and would like to know if it is poss for the css & php to change a
    HTML Code:
    <li>
    colour depending on the day off the week?

    i.e. monday=yellow...tuesday=bluee...wednesday, pink...etc

    Here is my html and css code

    HTML
    Code:
    <ul class="date">
    <li>
    <font class="number">1</font>
    <br />
    <?php include ("jan/1.txt"); ?>
    </li>
    <li>
    <font class="number">2</font>
    <br />
    <?php include ("jan/2.txt"); ?>
    </li>
    </ul>
    CSS
    Code:
    .number {
    	font-family: Verdana, Geneva, sans-serif;
    	font-size: 24px;
    	color: #F90;
    }
    .date li {
    	background-color:#FC0;
    	padding: 10px;
    	padding-top: 5px;
    	padding-bottom: 5px;
    	height: 100px;
    	width: 98px;
    	list-style-type: none;
    	float: left;
    	margin-right: 8px;
    	margin-bottom: 8px;
    }
    .date li:hover {
    	background-color:#FC3;
    }
    Thanks guys

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    You could use something like this:
    PHP Code:
    <?php 

    $weekday 
    = (date('l')); // get current day of weeek

    if ($weekday == 'Monday') {
    echo 
    'Today is Monday';
    echo 
    '<link rel="stylesheet" href="/monday-style.css" type="text/css"/>';
    // do something else for Monday

    else if (
    $weekday == 'Tuesday') {
    echo 
    'Today is Tuesday';
    echo 
    '<link rel="stylesheet" href="/tuesday-style.css" type="text/css"/>';
    // do something else for Tuesday

    else if (
    $weekday == 'Wednesday') {
    echo 
    'Today is Wednesday';
    echo 
    '<link rel="stylesheet" href="/wednesday-style.css" type="text/css"/>';
    // do something else for Wednesday
    }
    else if (
    $weekday == 'Thursday') {
    echo 
    'Today is Thursday';
    echo 
    '<link rel="stylesheet" href="/thursday-style.css" type="text/css"/>';
    // do something else for Thursday
    }
    else if (
    $weekday == 'Friday') {
    echo 
    'Today is Friday';
    echo 
    '<link rel="stylesheet" href="/friday-style.css" type="text/css"/>';
    // do something else for Friday
    }
    else if (
    $weekday == 'Saturday') {
    echo 
    'Today is Saturday';
    echo 
    '<link rel="stylesheet" href="/saturday-style.css" type="text/css"/>';
    // do something else for Saturday
    }
    else if (
    $weekday == 'Sunday') {
    echo 
    'Today is Sunday';
    echo 
    '<link rel="stylesheet" href="/sunday-style.css" type="text/css"/>';
    // do something else for Sunday
    }

    ?>
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •