Wrox Programmer Forums
|
BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3
This is the forum to discuss the Wrox book Beginning CSS: Cascading Style Sheets for Web Design by Richard York; ISBN: 9780764576423
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2005, 10:21 PM
Registered User
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Links after the <ul> tag

I have really gotten into using the list properties and have seen how efficient they are. I have a page that has links running down the left side of it, which are in the[list] tag (which is all inside of a <div> so I can place them). The problem that I have run into is that once I ended that <div> to the "navigation" side of my page, nothing after that point can be linked. I have tried to rearrange the order of the .html page but then I ran into the problem of the page not being layed out the way I wanted. The chapter in the book is Chapter 12. Below is a sample of the .html and the .css file I am using.







.css


<style="css/text" media="all">

    body {
        background: url('nav.jpg') repeat-y;
    }


    /**
     *Any text that is not labeled or defined
     **
    */
    * {
        font-family: serif;
        font-size: 12px;
        color: black;
        text-decoration: none;
    }
    /**
     *What goes on inside of the p tag
     **
    */
    p {
        font-family: serif;
        font-size: 14px;
        color: black;
        text-decoration: none;
    }
    /**
     *Links
     **
    */
    ul {
        list-style: none;
    }
    li {
        border: 1.5px outset black;
        width: 180px;
        height: 20px;
        padding: 5px;
        background-color: silver;
        -moz-border-radius: 10%;
        font-size: 16px;
        text-align: center;
        margin-top: 4px;
    }
    li a {
        padding: 2px;
        text-decoration: none;
    }
    li a:link {
        color: black;
    }
    li a:visited {
        color: black;
        background-color: silver;
    }
    li a:hover {
        color: black;
        background-color: silver;
        text-decoration: underline;
    }
    li a:active {
        color: black;
        background-color: white;
    }
    /**
     *Navigation Buttons
     **
    */
    div#navigation {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: url('nav.jpg');
        background-repeat: repeat-y;
        height: 1200px;
    }
    /**
     *Top border and div
     **
    */
    div.top {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: url('top.jpg');
        background-repeat: repeat-x;
        height: 225px;
    }
    /**
     *Title in top div
     **
    */
    div.toptitle {
        padding: 30px;
        font-size: 60px;
        color: silver;
        text-decoration: oblique;
        font-weight: bold;
        text-align: center;
        text-indent: 230px;
    }
    /**
     *Alignment of the panoramic
     **
    */
    div.panoramic {
        left: 260px;
    }
    /**
     *Address, Phone Number, and Fax Number
     **
    */
    div#contact {
        font-size: 18px;
        color: black;
        font-family: cursive;
        text-decoration: italic;
        text-align: center;
        left: 260px;
    }
    p#space {
        word-spacing: 10px;
    }
    div#numbers {
        font-size: 16px;
        color: black;
        font-family: cursive;
        text-decoration: italic;
        text-align: center;
        left: 260px;
    }
    div.wcboemsde {
        padding-left: 225px;
        width: 900px;
        padding-top: -500px;
    }
    p#wcboemsde {
        width: 900px;
        font-size: 20px;
        text-align: center;
        padding-top: 10px;
    }
    div.scrollingevents {
        padding-left: 850px;
        width: 200px;
    }
    a {
        color: blue;
        text-decoration: none;
    }
    a:link {
        color: blue;
    }
    a:visited {
        color: lighblue
    }
    a:hover, a:active {
        color: blue;
        background: silver;
        text-decoration: underline;
        font-weight: bold;
    }
</style>


.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.02 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<head>

<title>title</title>

<link rel="stylesheet" href="main.css" type="text/css" />








<style type="text/css">



#memoryticker{

background-color: lightyellow;

width: 450px;

font: bold 12px Verdana;

/*Tip: add in height attribute here for multiple line scroller*/

border: 1px solid black;

padding: 3px;

/*Change 0.7 below to a different number if desired (0.7=0.7 seconds)*/

/*Remove below line to remove transitional effect in IE. Below line should always appear last within this CSS*/

filter: progid:DXImageTransform.Microsoft.GradientWipe(Gra dientSize=1.0 Duration=0.7)

}



</style>

<body Onload="scrollnews(0)">

<div class='top'>

<div class='toptitle'>

title

<br>

<div id='panoramic'>

<img src=".gif" float:'right'>

</div>

<div id='contact'>

address

</div>

<div id='numbers'>

Phone #

</div>

<div id='numbers'>

Fax #

</div>






<div class='scrollingevents'>

<script type="text/javascript">



/***********************************************

* Memory Ticker script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)

* This notice MUST stay intact for legal use

* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code

***********************************************/



//configure tickercontents[] to set the messges you wish be displayed (HTML codes accepted)

//Backslash any apostrophes within your text (ie: I\'m the king of the world!)

var tickercontents=new Array()

tickercontents[0]='1) <a href="http://www.javascriptkit.com">JavaScriptKit.com</a>- JavaScript tutorials and scripts.</a>'

tickercontents[1]='2) <a href="http://www.codingforums.com">Coding Forums</a>- Web coding and development forums.</a>'

tickercontents[2]='3) <a href="http://www.dynamicdrive.com">DynamicDrive.com</a>- Award winning, original DHTML scripts.</a>'

tickercontents[3]='4) <a href="http://www.freewarejava.com">FreewareJava</a>- Free Java applets, tutorials, and resources.</a>'



var persistlastviewedmsg=1 //should messages' order persist after users navigate away (1=yes, 0=no)?

var persistmsgbehavior="onload" //set to "onload" or "onclick".



//configure the below variable to determine the delay between ticking of messages (in miliseconds):

var tickdelay=3000



////Do not edit pass this line////////////////



var divonclick=(persistlastviewedmsg && persistmsgbehavior=="onclick")? 'onClick="savelastmsg()" ' : ''

var currentmessage=0



function changetickercontent(){

if (crosstick.filters && crosstick.filters.length>0)

crosstick.filters[0].Apply()

crosstick.innerHTML=tickercontents[currentmessage]

if (crosstick.filters && crosstick.filters.length>0)

crosstick.filters[0].Play()

currentmessage=(currentmessage==tickercontents.len gth-1)? currentmessage=0 : currentmessage+1

var filterduration=(crosstick.filters&&crosstick.filte rs.length>0)? crosstick.filters[0].duration*1000 : 0

setTimeout("changetickercontent()",tickdelay+filte rduration)

}



function beginticker(){

if (persistlastviewedmsg && get_cookie("lastmsgnum")!="")

revivelastmsg()

crosstick=document.getElementById? document.getElementById("memoryticker") : document.all.memoryticker

changetickercontent()

}



function get_cookie(Name) {

var search = Name + "="

var returnvalue = ""

if (document.cookie.length > 0) {

offset = document.cookie.indexOf(search)

if (offset != -1) {

offset += search.length

end = document.cookie.indexOf(";", offset)

if (end == -1)

end = document.cookie.length;

returnvalue=unescape(document.cookie.substring(off set, end))

}

}

return returnvalue;

}



function savelastmsg(){

document.cookie="lastmsgnum="+currentmessage

}



function revivelastmsg(){

currentmessage=parseInt(get_cookie("lastmsgnum"))

currentmessage=(currentmessage==0)? tickercontents.length-1 : currentmessage-1

}



if (persistlastviewedmsg && persistmsgbehavior=="onload")

window.onunload=savelastmsg



if (document.all||document.getElementById)

document.write('<div id="memoryticker" '+divonclick+'></div>')

if (window.addEventListener)

window.addEventListener("load", beginticker, false)

else if (window.attachEvent)

window.attachEvent("onload", beginticker)

else if (document.all || document.getElementById)

window.onload=beginticker



</script>

</div>










</div>


<div id='navigation'>

<img src="topleft.jpg">
[list]

<li><a href="index.html">Homepage</a><Br><br></li>

<li><a href="guidance.html">Guidance</a><br><br></li>

<li><a href="facilities.html">Facilities</a><br><br></li>

<li><a href="academiclass.html">Academic Classes</a><br><br></li>

<li><a href="alumni.html">Alumni</a><br><br></li>

<li><a href="arts.html">Arts</a><br><br></li>

<li><a href="sporthome.html">Sports</a><br><br></li>

<li><a href="afg.html">Accreditation for Growth</a><br><br></li>

<li><a href="afterschool.html">After School</a><br><br></li>

<li><a href="media.html">Media Center</a><br><br></li>

<li><a href="technology.html">Technology</a><br><br></li>

<li><a href="news-front.html">Newspaper</a><br><br></li>

<li><a href="calendar.html">School Calendar</a><br><br></li>

<li><a href="newsletter.pdf">Newsletter</a><br><br></li>

<li><a href="parents.html">Parents</a><br><br></li>

<li><a href="testing.html">Testing</a><br><br></li>

</ul>

</div>










<div class='wcboemsde'>

<center>

<p id='wcboemsde'>

<a href='http://www..com/' target='_blank'><img src='msde.gif'><br>State Department of Education</a><br><br><a href='http://www.w' target='_blank'><img src='wcboe.jpg'><br>Board of Ed</a>

</p>

</center>

</div>











</div>

</body>

</html>

 
Old May 15th, 2005, 10:59 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

First things first. If you want to solicit the help of a hacker, please take the time to make your code neat and orderly. Sometimes you're even likely to uncover the source of the problem while doing so. You being a newbie, I have some sympathy, but most people don't. In fact I'm willing to bet posting a mess like that anywhere would likely draw zero replies. Hackers like myself don't want to spend ten minutes of their day formatting your code just so it can be read. The best thing to do is make neat, orderly markup. Once you've done so, then run it through the W3C HTML validator at http://validator.w3.org. Fix all the errors that it points out. If you don't understand an error, ask about it. Then, if you still can't figure out your problem, post some links to the code. This is better because I don't have to spend any time copying and pasting your code and loading it into a browser.

See also: http://www.catb.org/~esr/faqs/smart-questions.html

That said, let's get to the bottom of this linking problem.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.02 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
    <head>
        <title>title</title>

        <style type="text/css" media="all"> 

            body {
                background: url('nav.jpg') repeat-y;
            }
            /**
             *Any text that is not labeled or defined
             **
            */
            * {
                font-family: serif;
                font-size: 12px;
                color: black;
                text-decoration: none;
            }
            /**
             *What goes on inside of the p tag
             **
            */
            p {
                font-family: serif;
                font-size: 14px;
                color: black;
                text-decoration: none;
            }
            /**
             *Links
             **
            */
            ul {
                list-style: none;
            }
            li  {
                border: 1.5px outset black;
                width: 180px;
                height: 20px;
                padding: 5px;
                background-color: silver;
                -moz-border-radius: 10%;
                font-size: 16px;
                text-align: center;
                margin-top: 4px;
            }
            li a {
                padding: 2px;
                text-decoration: none;
            }
            li a:link {
                color: black;
            }
            li a:visited {
                color: black;
                background-color: silver;
            }
            li a:hover {
                color: black;
                background-color: silver;
                text-decoration: underline;
            }
            li a:active {
                color: black;
                background-color: white;
            }
            /**
             *Navigation Buttons
             **
            */
            div#navigation {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-image: url('nav.jpg');
                background-repeat: repeat-y;
                height: 1200px;
            }
            /**
             *Top border and div
             **
            */
            div.top {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-image: url('top.jpg');
                background-repeat: repeat-x;
                height: 225px;
            }
            /**
             *Title in top div
             **
            */
            div.toptitle {
                padding: 30px;
                font-size: 60px;
                color: silver;
                text-decoration: oblique;
                font-weight: bold;
                text-align: center;
                text-indent: 230px;
            }
            /**
             *Alignment of the panoramic
             **
            */
            div.panoramic {
                left: 260px;
            }
            /**
             *Address, Phone Number, and Fax Number
             **
            */
            div#contact {
                font-size: 18px;
                color: black;
                font-family: cursive;
                text-decoration: italic;
                text-align: center;
                left: 260px;
            }
            p#space {
                word-spacing: 10px;
            }
            div#numbers {
                font-size: 16px;
                color: black;
                font-family: cursive;
                text-decoration: italic;
                text-align: center;
                left: 260px;
            }
            div.wcboemsde {
                padding-left: 225px;
                width: 900px;
                padding-top: -500px;
            }
            p#wcboemsde {
                width: 900px;
                font-size: 20px;
                text-align: center;
                padding-top: 10px;
            }
            div.scrollingevents {
                padding-left: 850px;
                width: 200px;
            }
            a {
                color: blue;
                text-decoration: none;
            }
            a:link {
                color: blue;
            }
            a:visited {
                color: lighblue
            }
            a:hover, a:active {
                color: blue;
                background: silver;
                text-decoration: underline;
                font-weight: bold;
            }
        </style>
        <style type="text/css">
            #memoryticker {
                background-color: lightyellow;        
                width: 450px;
                font: bold 12px Verdana;
                /*Tip: add in height attribute here for multiple line scroller*/
                border: 1px solid black;        
                padding: 3px;
                /*Change 0.7 below to a different number if desired (0.7=0.7 seconds)*/
                /*Remove below line to remove transitional effect in IE. Below line should always appear last within this CSS*/        
                filter: progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)        
            }
        </style>

    </head>
    <body Onload="scrollnews(0)">
        <div class='top'>
            <div class='toptitle'>
                title<br>
                <div id='panoramic'>
                    <img src=".gif" float:'right'>
                </div>
                <div id='contact'>
                    address
                </div>
                <div id='numbers'>
                    Phone #
                </div>
                <div id='numbers'>
                    Fax #
                </div>
                <div class='scrollingevents'>
                    <script type="text/javascript">

                        var tickercontents=new Array()

                        tickercontents[0]='1) <a href="http://www.javascriptkit.com">JavaScriptKit.com</a>- JavaScript tutorials and scripts.</a>'
                        tickercontents[1]='2) <a href="http://www.codingforums.com">Coding Forums</a>- Web coding and development forums.</a>'
                        tickercontents[2]='3) <a href="http://www.dynamicdrive.com">DynamicDrive.com</a>- Award winning, original DHTML scripts.</a>'
                        tickercontents[3]='4) <a href="http://www.freewarejava.com">FreewareJava</a>- Free Java applets, tutorials, and resources.</a>'

                        var persistlastviewedmsg=1 //should messages' order persist after users navigate away (1=yes, 0=no)?
                        var persistmsgbehavior="onload" //set to "onload" or "onclick".

                        //configure the below variable to determine the delay between ticking of messages (in miliseconds):
                        var tickdelay=3000

                        ////Do not edit pass this line////////////////

                        var divonclick=(persistlastviewedmsg && persistmsgbehavior=="onclick")? 'onClick="savelastmsg()" ' : ''
                        var currentmessage=0

                        function changetickercontent()
                        {
                            if (crosstick.filters && crosstick.filters.length>0)
                                crosstick.filters[0].Apply()

                            crosstick.innerHTML=tickercontents[currentmessage]

                            if (crosstick.filters && crosstick.filters.length>0)
                                crosstick.filters[0].Play()

                            currentmessage=(currentmessage==tickercontents.length-1)? currentmessage=0 : currentmessage+1

                            var filterduration=(crosstick.filters&&crosstick.filters.length>0)? crosstick.filters[0].duration*1000 : 0

                            setTimeout("changetickercontent()",tickdelay+filterduration)
                        }

                        function beginticker()
                        {
                            if (persistlastviewedmsg && get_cookie("lastmsgnum")!="")
                                revivelastmsg()

                            crosstick=document.getElementById? document.getElementById("memoryticker") : document.all.memoryticker        
                            changetickercontent()
                        }

                        function get_cookie(Name)
                        {
                            var search = Name + "="
                            var returnvalue = ""

                            if (document.cookie.length > 0)
                            {
                                offset = document.cookie.indexOf(search)

                                if (offset != -1)
                                {
                                    offset += search.length
                                    end = document.cookie.indexOf(";", offset)

                                    if (end == -1)
                                        end = document.cookie.length;

                                    returnvalue=unescape(document.cookie.substring(offset, end))
                                }
                            }
                            return returnvalue;
                        }

                        function savelastmsg()
                        {
                            document.cookie="lastmsgnum="+currentmessage
                        }

                        function revivelastmsg()
                        {
                            currentmessage=parseInt(get_cookie("lastmsgnum"))
                            currentmessage=(currentmessage==0)? tickercontents.length-1 : currentmessage-1
                        }

                        if (persistlastviewedmsg && persistmsgbehavior=="onload")
                            window.onunload=savelastmsg

                        if (document.all||document.getElementById)
                            document.write('<div id="memoryticker" '+divonclick+'></div>')

                        if (window.addEventListener)
                            window.addEventListener("load", beginticker, false)
                        else if (window.attachEvent)
                            window.attachEvent("onload", beginticker)
                        else if (document.all || document.getElementById)
                            window.onload=beginticker
                    </script>
                </div>
            </div>
            <div id='navigation'>
                <img src="topleft.jpg">
                [list]
                    <li><a href="index.html">Homepage</a><Br><br></li>                    
                    <li><a href="guidance.html">Guidance</a><br><br></li>
                    <li><a href="facilities.html">Facilities</a><br><br></li>
                    <li><a href="academiclass.html">Academic Classes</a><br><br></li>
                    <li><a href="alumni.html">Alumni</a><br><br></li>
                    <li><a href="arts.html">Arts</a><br><br></li>
                    <li><a href="sporthome.html">Sports</a><br><br></li>
                    <li><a href="afg.html">Accreditation for Growth</a><br><br></li>
                    <li><a href="afterschool.html">After School</a><br><br></li>
                    <li><a href="media.html">Media Center</a><br><br></li>
                    <li><a href="technology.html">Technology</a><br><br></li>
                    <li><a href="news-front.html">Newspaper</a><br><br></li>
                    <li><a href="calendar.html">School Calendar</a><br><br></li>
                    <li><a href="newsletter.pdf">Newsletter</a><br><br></li>
                    <li><a href="parents.html">Parents</a><br><br></li>
                    <li><a href="testing.html">Testing</a><br><br></li>
                </ul>
            </div>
            <div class='wcboemsde'>
                <center>
                    <p id='wcboemsde'>
                        <a href='http://www..com/' target='_blank'><img src='msde.gif'><br>State Department of Education</a><br><br>
                        <a href='http://www.w' target='_blank'><img src='wcboe.jpg'><br>Board of Ed</a>
                    </p>
                </center>
            </div>
        </div>
    </body>
</html>
Ok, when you have problems with links suddenly not working, what you actually have is a layering issue. To debug such a problem, first identify every element that is absolutely positioned. In the style sheet you can do this by adding borders or backgrounds to those elements until the offending layer is clearly highlighted.
Code:
            /**
             *Navigation Buttons
             **
            */
            div#navigation {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-image: url('nav.jpg');
                background-repeat: repeat-y;
                height: 1200px;
                border: 1px solid black;
                background: grey;
            }
            /**
             *Top border and div
             **
            */
            div.top {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-image: url('top.jpg');
                background-repeat: repeat-x;
                height: 225px;
                border: 2px solid yellow;
                background: lightyellow;
            }
After adding borders and backgrounds to the two absolutely positioned elements it is clear what is happening, the navigation div is layered above those links. Even though its background is transparent, it still exists above the other content, which is why those links don't work.

Solution: Remove the right: 0; declaration, and specify a fixed width, or simply allow the element to go by its default behavior, which is shrink-to-fit, essentially it will be as wide as the content inside of it.
Code:
            div#navigation {
                position: absolute;
                top: 0;
                left: 0;
                bottom: 0;
                background-image: url('nav.jpg');
                background-repeat: repeat-y;
                height: 1200px;
                border: 1px solid black;
                background: grey;
            }
Now it is no longer above the other links.

HTH!


Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB: Insert <p> tag Rich57 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 October 12th, 2007 05:19 AM
<a> tag in XML sani723 XSLT 5 March 27th, 2007 04:16 AM
create <ul> with alternating class on <li> element Brian Campbell XSLT 2 November 3rd, 2006 06:07 PM
dynamic <input> tag Val Javascript 1 September 6th, 2006 02:55 AM
<Form> tag within <form> tag rit01 ASP.NET 2.0 Basics 3 April 23rd, 2006 08:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.