Results 1 to 13 of 13

Thread: [resolved]Calendar navigation

  1. #1

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Resolved [resolved]Calendar navigation

    I'm making a calendar but I'm having troubles with the navigation. I want it to look like this:
    Code:
    <<       1       >>
    <<    October    >>
    <<     2004      >>
    The thing is that I don't want to use tables, but I do want it to work even if the user doesn't use stylesheets. Any ideas anyone?

    //Tobbe
    Last edited by McCain; Oct 11th, 2004 at 10:03 AM.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You could make it so that it degrades if the user doesn't use stylesheets. To something like
    << 1 >>
    << October >>
    << 2004 >>

    It's not as beautiful, but that's HTML without CSS: not beautiful.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    Yeah, that's exactly what I want, but I can't make it work

    When I disable the css I got right now I get this:
    <<
    <<
    <<
    1
    October
    2004
    >>
    >>
    >>

    And that is not good enough...
    Last edited by McCain; Oct 3rd, 2004 at 05:14 PM.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  4. #4

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    The code I have right now, that I don't think is good enough looks like this:
    Code:
    <div id="datenav">
    	<div class="left">
    		<a href="./calendar.php?day=<?php echo $aDay-1;?>&month=<?php echo $aMonth;?>&year=<?php echo $aYear;?>">&lt;&lt;</a><br />
    		<a href="./calendar.php?day=<?php echo $aDay;?>&month=<?php echo $aMonth-1;?>&year=<?php echo $aYear;?>">&lt;&lt;</a><br />
    		<a href="./calendar.php?day=<?php echo $aDay;?>&month=<?php echo $aMonth;?>&year=<?php echo $aYear-1;?>">&lt;&lt;</a><br />
    	</div>
    	<div class="middle">
    		<?php echo $aDay ?><br />
    		<?php echo $sweMonths[$aMonth - 1] ?><br />
    		<?php echo $aYear ?><br />
    	</div>
    	<div class="right">
    		<a href="./calendar.php?day=<?php echo $aDay+1;?>&month=<?php echo $aMonth;?>&year=<?php echo $aYear;?>">&gt;&gt;</a><br />
    		<a href="./calendar.php?day=<?php echo $aDay;?>&month=<?php echo $aMonth+1;?>&year=<?php echo $aYear;?>">&gt;&gt;</a><br />
    		<a href="./calendar.php?day=<?php echo $aDay;?>&month=<?php echo $aMonth;?>&year=<?php echo $aYear+1;?>">&gt;&gt;</a><br />				
    	</div>
    </div>
    And here's the CSS:
    Code:
    div#datenav
    {
    	position: relative;
    	line-height: 1.8em;
    	width: 12em;
    	margin: auto;
    	padding-bottom: 20px;
    	text-align: left;
    }
    
    div#datenav div.left
    {
    	position: relative;
    	left: 0;
    	top: 0;
    	width: 2em;
    	font-weight: bolder;
    }
    
    div#datenav div.middle
    {
    	position: absolute;
    	left: 2em;
    	top: 0;
    	width: 8em;
    	text-align: center;
    }
    
    div#datenav div.right
    {
    	position: absolute;
    	left: 10em;
    	top: 0;
    	width: 2em;
    	font-weight: bolder;
    }
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    So reorder it:
    Code:
    <div class="calnavline">
    <a class="calnavback" href="...">&lt;&lt;</a>
    <span class="calnavnum">$day</span>
    <a class="calnavfwd" href="...">&gt;&gt;</a>
    <!-- This is an unfortunate necessity in IE:
    <br class="clearer"/>
    </div>
    <div class="calnavline">
    <a class="calnavback" href="...">&lt;&lt;</a>
    <span class="calnavnum">$month</span>
    <a class="calnavfwd" href="...">&gt;&gt;</a>
    <!-- This is an unfortunate necessity in IE:
    <br class="clearer"/>
    </div>
    <div class="calnavline">
    <a class="calnavback" href="...">&lt;&lt;</a>
    <span class="calnavnum">$year</span>
    <a class="calnavfwd" href="...">&gt;&gt;</a>
    <!-- This is an unfortunate necessity in IE:
    <br class="clearer"/>
    </div>
    
    CSS:
    .calnavback, .calnavfwd {
      float: left;
      width: 3em;
      text-align: center;
    }
    .calnavnum {
      float: left;
      width: 7em;
      text-align: center;
    }
    .clearer {
      clear: both;
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    Thank you, I will try it as soon as I get home
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  7. #7

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    Worked like a charm (not that I expected anything else, comming from you and all...)

    Thanks
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  8. #8

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    I tried the code you gave me in IE6 today. I couldn't believe my eyes! This is what it looks like:

    Where does the extra > come from?
    This is the code:
    Code:
    <div id="datenav">		
    	<div class="calnavline">
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'day', -1);?>" class="calnavback">&lt;&lt;</a>
    		<span class="calnavnum"><?php echo $aDay ?></span>
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'day', +1);?>" class="calnavfwd">&gt;&gt;</a>
    		<!-- This is an unfortunate necessity in IE: -->
    		<br class="clearer" />
    	</div>
    	<div class="calnavline">
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'month', -1);?>" class="calnavback">&lt;&lt;</a>
    		<span class="calnavnum"><?php echo $sweMonths[$aMonth - 1] ?></span>
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'month', +1);?>" class="calnavfwd">&gt;&gt;</a>
    		<!-- This is an unfortunate necessity in IE: -->
    		<br class="clearer" />
    	</div>
    	<div class="calnavline">
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'year', -1);?>" class="calnavback">&lt;&lt;</a>
    		<span class="calnavnum"><?php echo $aYear ?></span>
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'year', +1);?>" class="calnavfwd">&gt;&gt;</a>end
    	</div>
    </div>
    Code:
    div#datenav
    {
    	position: relative;
    	line-height: 1.8em;
    	width: 13em;
    	margin: auto;
    	padding-bottom: 20px;
    	text-align: left;
    }
    
    div#datenav a
    {
    	color: #765;
    	text-decoration: none;
    }
    
    div#datenav a:hover
    {
    	color: #000;
    }
    
    .calnavback, .calnavfwd 
    {
    	float: left;
    	width: 3em;
    	text-align: center;
    	font-weight: bolder;
    }
    
    .calnavnum 
    {
    	float: left;
    	width: 7em;
    	text-align: center;
    }
    
    .clearer 
    {
    	clear: both;
    }
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    If you're using a HTML doctype, I'd say it comes from an actually correct SGML parse of the HTML code, thus making the > in <br /> show up. The weird thing about "HTML-compatible" XHTML 1.0 is that it relies on a parsing bug in what I thought was every single generic web browser available.

    If you're using a HTML doctype, use the normal <br>. If you're using an XHTML doctype - perhaps you shouldn't. IE doesn't support XHTML anyway, it only pretends it does.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    I'm using xhtml

    But if I change "class="calnavfwd">&gt;&gt;</a>" to "class="calnavfwd">bb</a>" it will show a 'b' on the next line.
    Last edited by McCain; Oct 11th, 2004 at 03:53 AM.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Oh, then it's a layout bug. It might even be one I've heard of. Let me think...

    Found it:
    http://www.positioniseverything.net/...haracters.html

    Apparently you need to remove the comments.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    I removed the comments. Didn't help.

    The code:
    Code:
    <div id="datenav">		
    	<div class="calnavline">
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'day', -1);?>" class="calnavback">&lt;&lt;</a>
    		<span class="calnavnum"><?php echo $aDay ?></span>
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'day', +1);?>" class="calnavfwd">&gt;&gt;</a>
    		<br class="clearer" />
    	</div>
    	<div class="calnavline">
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'month', -1);?>" class="calnavback">&lt;&lt;</a>
    		<span class="calnavnum"><?php echo $sweMonths[$aMonth - 1] ?></span>
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'month', +1);?>" class="calnavfwd">&gt;&gt;</a>
    		<br class="clearer" />
    	</div>
    	<div class="calnavline">
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'year', -1);?>" class="calnavback">&lt;&lt;</a>
    		<span class="calnavnum"><?php echo $aYear ?></span>
    		<a href="./calendar.php?<?php echo newLinkDate($aDay, $aMonth, $aYear, 'year', +1);?>" class="calnavfwd">bb</a>end
    	</div>
    </div>
    Still the same CSS
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  13. #13

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    I have no idea what caused the bug, but I have fixed it by doing what they suggested att pie.
    Fixes and Workarounds
    One easy fix is to put a -3px right margin on the last left float.
    So I changed my CSS to this:
    Code:
    .calnavback, .calnavfwd 
    {
    	float: left;
    	width: 3em;
    	text-align: center;
    	font-weight: bolder;
    	margin-right: -3px;
    }
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

Posting Permissions

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



Click Here to Expand Forum to Full Width