HTML - Bullet Points And Image Overlap
Hi I've been having a lot of problems with images and bullet points overlapping, what I mean by that is I'll align an image to left allignment, it goes to the left of the text but the bullet points are superimposed over the top also the picture is being included in the list instead of to the left of the list as i want. here's a screenshot and the code of the page in question and the stylesheet, Thanks very much, I'm going mad trying to work it out:
screenshot: page code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/index.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>.:Max Barr Antique Furniture Restoration:.</title> <style type="text/css" media="all"> <!-- @import url("styles.css"); #header #logo a { font-family: Times New Roman, Times, serif; } #index #outerWrapper #gradient #contentWrapper br { color: #FFF; } #index #outerWrapper #gradient div { color: #FFF; } --> </style> <!-- InstanceBeginEditable name="gallery info" --> <!-- <LINK HREF="styles/default.css" rel=stylesheet> --> <LINK HREF="../res/styles.css" rel=stylesheet> <style type="text/css"> <!-- .highslide { cursor: url(../res/graphics/zoomin.cur), pointer; outline: none; } .highslide img { border: 2px solid #999999; } .highslide:hover img { border: 2px solid #ffffff; } .highslide-overlay { display: none; } .highslide-image { border: solid #ffffff; } .highslide-caption { display: none; color: #000000; border: 0px solid #ffffff; border-top: none; font-family: Verdana, Helvetica; font-size: 10pt; padding: 5px; background-color: #ffffff; } .highslide-caption a {color: #2E8B57;} .highslide-loading, a.highslide-loading:link { display: block; color: #ffffff; background-color: #000000; font-size: 9pt; font-weight: bold; text-transform: uppercase; text-decoration: none; padding: 3px; border-top: 1px solid #ffffff; border-bottom: 1px solid #ffffff; padding-left: 22px; background-image: url(../res/graphics/loader.gif); background-repeat: no-repeat; background-position: 3px 1px; } a.highslide-credits, a.highslide-credits i { padding: 2px; color: silver; text-decoration: none; font-size: 10px; } a.highslide-credits:hover, a.highslide-credits:hover i { color: white; background-color: gray; } .highslide-move { cursor: move; } /* Controlbar */ .controlbar { background: url(../res/graphics/controlbar4.gif); width: 167px; height: 34px; } .controlbar a { display: block; float: left; /*margin: 0px 0 0 4px;*/ height: 27px; } .controlbar a:hover { background-image: url(../res/graphics/controlbar4-hover.gif); } .controlbar .previous { width: 50px; } .controlbar .next { width: 40px; background-position: -50px 0; } .controlbar .highslide-move { width: 40px; background-position: -90px 0; } .controlbar .close { width: 36px; background-position: -130px 0; } .highslide-dimming { background: #000000; position: absolute; visibility: hidden; } a.highslide-full-expand { background: url(../res/graphics/fullexpand.gif) no-repeat; display: block; margin: 10px 10px 10px 10px; width: 34px; height: 34px; } .highslide-active-anchor img { visibility: hidden } .highslide-html { background-color: white; } .highslide-html-blur { } .highslide-html-content { position: absolute; display: none; } /* Necessary for functionality */ .highslide-display-block { display: block; } .highslide-display-none { display: none; } --> </style> <link rel="alternate" href="album.rss" type="application/rss+xml"> <style type="text/css"> <!-- .highslide { cursor: url(../res/graphics/zoomin.cur), pointer; outline: none; } .highslide-caption { display: none; color: #000000; border: 0px solid #ffffff; border-top: none; font-family: Verdana, Helvetica; font-size: 10pt; padding: 5px; background-color: #ffffff; } #index #outerWrapper #gradient #contentWrapper #content p { font-size: 10px; } #index #outerWrapper #gradient #contentWrapper #content p { font-size: 12px; } #index #outerWrapper #gradient #contentWrapper #content { font-size: small; } --> </style> <!-- InstanceEndEditable --> <!--[if IE 5]> <style type="text/css"> #outerWrapper #contentWrapper #leftColumn1 { width: 200px; } </style> <![endif]--> <!--[if IE]> <style type="text/css"> #outerWrapper #contentWrapper #content { zoom: 1; } </style> <![endif]--> </head> <body id="index"> <div id="header"> <div id="logo"> <a href="index.html" onmouseover=""> Max Barr Antique Restoration</a></div> </div> <div id="outerWrapper"> <div id="gradient"> <div id="nav" style="margin-bottom: 10px;"> <div align="center"> <ul> <li><a href="http://www.maxbarr.com/index.html">Home</a></li> <li><a href="http://www.maxbarr.com/profile.html">Profile</a></li> <li><a href="http://www.maxbarr.com/restoration.html">Restoration</a></li> <li><a href="http://www.maxbarr.com//gallery/index.html">Gallery</a></li> <li><a href="http://www.maxbarr.com/contact.html">Contact</a></li> </ul> </div> </div> <div id="contentWrapper"> <div align="center"></div> <div id="content"> <!-- InstanceBeginEditable name="Content" --> <p align="center"><img src="P6030553.gif" width="75" height="54" /><img src="img064.gif" width="82" height="54" /><img src="P5300085.gif" width="71" height="54" /><img src="PB040728.gif" width="83" height="53" /><img src="images/P9150206.gif" width="65" height="54" /><img src="images/PB110751.gif" width="79" height="55" /><img src="images/img069.gif" width="84" height="56" /><img src="images/P8310186.gif" width="78" height="56" /></p> <p>Welcome to my website. I have been making furniture and restoring antiques here in Gloucestershire for 18 years. I have a large, well equipped workshop and carry out work for both private clients and the quality antiques trade. Examples of my restoration work have been shown at many national and international antiques fairs including London Olympia, Maastricht Tefaf and Chicago Artropolis. <img src="images/WmIVthreePillar55__x135__4.gif" width="348" height="181" align="middle" /><br /> <br /> High standards of work and customer satisfaction are my top priorities. If you would like to discuss any project, large or small, please give me a call for friendly expert advice.</p> <p>Services include:</p> <ul> <li><img src="images/img071.gif" width="113" height="169" align="left" />High quality restoration and repair to all kinds of furniture. </li> Replacement or repair of damaged or missing woodwork from chips of veneer to entire legs or table leaves using appropriate materials and techniques. <img src="images/P9010139.gif" width="157" height="118" align="right" /></li> <li>Restoration of existing finishes, reviving, colour matching, disguising of repairs</li> <li>Traditional French polishing, wax polishing and oil finishes</li> <li>Repairs to locks, castors, handles and other metalwork </li> Supply and fitting of leather or baize desk-top liners.</li> <li>Upholstery, cane and rush-work seating. </ul> </p> </li> </ul> <p> </p> <h1 align="justify"><img src="images/P3080182.gif" width="147" height="110" align="bottom" /></h1> <p> </p> <div id="controlbar" class="highslide-overlay controlbar"> <a href="#" class="previous" onClick="return hs.previous(this)" title="Previous (left arrow key)"></a> <a href="#" class="next" onClick="return hs.next(this)" title="Next (right arrow key)"></a> <a href="#" class="highslide-move" onClick="return false" title="Click and drag to move"></a> <a href="#" class="close" onClick="return hs.close(this)" title="Close"></a> </div> <!-- Bottom navigation --> <div id="jalbumwidgetcontainer"></div> <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- _jaSkin = "Boxer"; _jaStyle = "2 Purple Pavement.css"; _jaVersion = "8.1.6"; _jaLanguage = "en"; _jaPageType = "index"; _jaRootPath = ".."; var script = document.createElement("script"); script.type = "text/javascript"; script.src = "http://jalbum.net/widgetapi/load.js"; document.getElementById("jalbumwidgetcontainer").appendChild(script); //--><!]]></script> <!-- InstanceEndEditable --></div> </div> <div id="credit" align="center">Copyright © 2009 Max Barr <br /> </div> </div> </div> </body> <!-- InstanceEnd --></html> Similar TutorialsThis is not my expertise and you guys are a great help! I've got all of the copy on the page, but everything is along the left margin. I want to indent a few bullet points and paragraphs. What html do I use? Thx. Hi, I have just joined the forum, so hello!! Although the standard margins for bullets are fine for what I want, I find when they are to the right of an image they have a different indent. I have managed to correct this in FF by using <li style="margin-left:40px"> but the bullets are invisible with IE. Any ideas? Hi, I've got a page with links to anchor points but clicking on it makes the popup open in a new window which I don't want to do, I just want it to snap to the anchor on the page. I've tried a few types... <li><a href="#faq_101605">What sort of feedback do you get from other advertisers?</a> </li> <p><a name="faq_101605" title="faq_101605"></a></p> ...and... <li><a href="http://dev.mysite.com.au/advertise/advertisers-faq.htm#faq_101498">How long will my advert stay on your web site?</a> </li> <p><a name="faq_101498" title="faq_101498"></a> Any help would be great. Thanks hi, i put a drop down menu on the top of my website. After that is a flash banner, but the banner is overlap my drop down menu so it can't be seen by user. how to solve this? Hi Buddies, I have created web travel based site, in my site, div border overlap in banner. http://webtravel.freehostia.com/ and also some times the menu mouse over images appears slowly. Please advise me. Cheers, Vijayakumar B Web Developer Hi, I know this is being an extreme perfectionist. But, if you look at http://www.tendervendors.com/dev/hr_systems.html, at the selected link on the navigation bar (HR Systems), you'll see that there are 2 lines either side of the HR Systems (selected) link. This is fine, however because the bottom border is on the other links and not the selected one, and the two side borders are on the selected link, the don't line up. I'm aware that i could specify the right border on the 1st link and the left border on the 3rd link, but i was trying to make it simple, so someone without alot of understanding and program it after i've done. So, i then thought, well i could overlap the links, 2px to the left, so set li { position:relative }, and then li {left:-2px}. but it doesn't overlap the li's, it overlaps the entire ul over the page (content div) border. Any ideas as to why this is? Thanks, Matthew Millar Code: <html> <head> <style type="text/css"> .maintable { position:fixed; top:20px; } body { height: 1000px; } </style> </head> <body> <h1>This is a heading</h1> <table class="maintable"> <tr> <td>00001</td> <td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td><td>00001</td> </tr> </table> <table> <tr> <td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td> </tr> </table> </body> </html> If I do that this is heading , and maintable overlap in firefox.but in ie they come below each other??? why? I would like it to overlap in ie as well. If I SCROLL in firefox, the maintable overlaps with the other table as well when table 2 becomes at position 20 px on scroll. In ie's case, on scroll the maintable disappears and doesnt stay fixed in position 20 px. help? Hi- So i have this problem that i cant find a solution for. i am making a web page and on the web page is an accordian nav menu. i am editing it in dreamweaver. Now, when i look at the page in livewiew it looks fine. BUT when i post the page on the internet there is this bullet next to my nav menu!! I cant find the code for it! all the <ul></ul> start and end when they are supossed to! and <li></li> ends when its supposed to too! im pulling my hair out with this bullet. what do i do? thanks Ok I'm trying to create an unordered list but I need two other seperate lines of text under each of the bullet lines of text' I'll see if I can give and example of what I need: (bullet) Day Spa www.dayspa.com A day spa treatment (bullet) Nelson Spa www.nelsonspa.com Full line spa (bullet) Whispering Spring Spa www.whisperingspring.com Full spa and resort when I do a simple UL and try to use <br> tags to create the different lines under each list, it wont validate and says I cant have a <br> inside a list. Also the bullets need to be black small squares, which, maybe I have over looked, cant seem to find the ascii codes for a small black square. I also get validation errors saying I cant have an "a" reference inside a list. So I tried to work around this by setting this up as a paragraph with <br> tags after each line and just find the ascii code and insert a square before the first line of each spa. Anyone know a way to accomplish this and still get the validation? Any help would be greatly appreciated! btw i made up the links but they seem to work! sorry but I wasnt trying to use real web links. Is there a way to set the color of the bullets for unordered lists? Hi, I have the html coding below that shows the bullet point with a caption below it. How would i format the actual bullet point to be a different size and colour to the caption below it? Thanks Code: <ol> <li>abc</li></br> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <li>abcd</li></br> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <li>abcde</li></br> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa </o> Hi how can i change the bullet to a number in an unordered list? this is what i want 1 etc 2 etc 3 etc can someone help Can anyone tell me if the following is possible, and if so, how do I do it? I want a list of bullet points, but if one of the bullet points has no text then I don't want the actual bullet graphic to be shown. Not the best explanation so I'll elaborate. I'm pulling the bullet data from a program using a keyword/macro so my code looks like this. HTML Code: <ul> <li>{{BulletPoint1}}</li> <li>{{BulletPoint2}}</li> <li>{{BulletPoint3}}</li> <li>{{BulletPoint4}}</li> <li>{{BulletPoint5}}</li> </ul> Works perfectly when all five bullet points are populated, but if for example, there are only 3 bullet points with text, I get the bottom two bullet graphics just hanging there with no text next to them so and the final code looks like this HTML Code: <ul> <li>This is bullet point 1</li> <li>Here's another bullet point</li> <li>Only 3 bullet points for this particular product</li> <li></li> <li></li> </ul> Can anyone help? Does anyone even know what I'm talking about? Hi there, i'm in the middle of setting up a shopping cart and have a little problem! I'm laying out the privacy page, and when I select numbered list for the formatting of some Terms and conditions, the numbers that run onto 2 lines are not indenting like the line above it. So the first line is indented with the number and the bottom line is aligned to the left. It looks untidy. It appears fine in dreamweaver but not when I upload to server. I'm sure there is a simple explanation for this, here is the address: http://www.thinking-forward.co.uk/privacy.cfm Hi all, Im having a problem with unordered lists. When I view it in Dreamweaver, the bullet points are small, but when I view in browser, they are huge. Ive tried adding classes to the CSS, but not sure what im doing wrong. Ive got one class that is: .bulletList { padding:0px; margin:12px; } I tried adding a different class for the actual lists: .bulletSize { font-size:12px; } But all this did was change the size of the font and not the size of the bullet point. Can anyone suggest what I could do to fix this? Thanks in advance How do you use make it so the space between BULLETS (HTML DISC) does not have such a large space between the lines when viewing between INTERNET EXPLORER and Any other browser like Firefox?? http://www.camarosource.ca/main_new_...new_layout.htm Right side "Recent Posts". You'll notice that if you view with Firefox that it shows the words close to get on top of each other. HOWEVER, View the same link in INTERNET EXPLORER and you'll soon discover it's now what's almost 1 more line inbetween the top words and the ones below them. How can I STOP THIS?? If I make it fit in Firefox, it's WAY too high in IE cause it adds another line. If I make it fit in IE, it's like 3/4 the height of the area for Firefox. Thanks! Hi all -- I'm having an interesting problem. I'm designing a web page that has a navigation banner (home - programs - schedule of events - contact us - downloads) that is made up of a .png for each page (i.e. home.png, programs.png, etc). My page is 1000px wide and all of the navigation banner's images add up to 1000px wide. I'm using JavaScript to create an onMouseOver and onMouseOut effect on each of the images. The problem that I'm having occurs when I tried to add a link (either by <A HREF= or using an image map). Whenever I add a link to the image, a small (3px) area of white space shows up to the right of the image. This shifts all of my other images 3px to the right (and 3 more for each link I add to subsequent images) thus making the total width of the navigation banner over 1000px and the last image gets shoved to a new line. I can find no way to get rid of this white space other than to remove the link from the image. There is no property on the page that adds any sort of padding, margins, or borders to images or links, so I can see no property that has to be changed. Help! How do I get rid of this white space but still keep the link on the image?? [I posted this question on the Adobe forum to no avail, below is a screencap I took of the issue I'm having] Thanks in advance! //kl PS - I am using both IE8 and Chrome to view this webpage. I've set all the margins/padding/borders to 0px. Here is my CSS and the part of the code that pertains to the navigation banner. CSS: Code: <style type="text/css"> <!-- body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: #666666; margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */ padding: 0; text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */ color: #000000; background-image: url(images/blue.bg.png); background-repeat: repeat; background-color: #009; } .oneColFixCtr #container { width: 1000px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */ background: #FFFFFF; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ border: 0px solid #000000; text-align: left; /* this overrides the text-align: center on the body element. */ } .oneColFixCtr #mainContent { padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */ } body, td, th { color: #333; } #main_banner2 { margin: 0px; padding: 0px; height: auto; width: 1000px; } --> </style> </head> Nav Banner: NOTE:: below HAS to be all one paragraph because if i insert a carriage return in between images, it also adds the white space... Code: <body class="oneColFixCtr"> <!-- MAIN NAVIGATION BANNER --> <!--HOME--><img src="images/nav/home.png" alt="home" name="home" width="82" height="30" border="0" onMouseOver="document.images.home.src='images/nav/home_over.png'" onMouseOut ="document.images.home.src='images/nav/home.png'"/><!--PROGRAMS--><img src="images/nav/programs.png" width="111" height="30" border="0" name="programs" onMouseOver="document.images.programs.src='images/nav/programs_over.png'" onMouseOut ="document.images.programs.src='images/nav/programs.png'"/><!--SCHEDULE OF EVENTS--><img src="images/nav/scheduleofevents.png" width="189" height="30" border="0" name="scheduleofevents" onMouseOver="document.images.scheduleofevents.src='images/nav/scheduleofevents_ over.png'" onMouseOut ="document.images.scheduleofevents.src='images/nav/scheduleofevents.png'"/><!-- CONTACT US--><img src="images/nav/contactus.png" width="119" height="30" border="0" name="contactus" onMouseOver="document.images.contactus.src='images/nav/contactus_over.png'" onMouseOut ="document.images.contactus.src='images/nav/contactus.png'"/><!--DOWNLOADS--><i mg src="images/nav/downloads.png" width="267" height="30" border="0" name="downloads" onMouseOver="document.images.downloads.src='images/nav/downloads_over.png'" onMouseOut ="document.images.downloads.src='images/nav/downloads.png'"/><!--FACEBOOK--><im g src="images/nav/facebook.png" width="90" height="30" border="0" name="facebook" onMouseOver="document.images.facebook.src='images/nav/facebook_over.png'" onMouseOut ="document.images.facebook.src='images/nav/facebook.png'"/><!--TWITTER--><img src="images/nav/twitter.png" width="67" height="30" border="0" name="twitter" onMouseOver="document.images.twitter.src='images/nav/twitter_over.png'" onMouseOut ="document.images.twitter.src='images/nav/twitter.png'"/><!--BLOGGER--><img src="images/nav/blogger.png" width="75" height="30" border="0" name="blogger" onMouseOver="document.images.blogger.src='images/nav/blogger_over.png'" onMouseOut ="document.images.blogger.src='images/nav/blogger.png'"/><img src="images/home_banner.png" alt="home_border" width="1000" height="7" /><br /> So in January 2006 I posted a question about "making two buttons in one" 3 years and 5 months later i am happy to announce that I have found a solution. Ok, so no I have not spent the last three years looking, but the need for one came around again yesterday so I revisited the project. All I needed was "simple" image toggle. Image 'A' click it once it changes to image 'B' click it again it changes back to image 'A' All the "image toggle" codes I could find were extremely complex. I thought I had finally found one, it wasn't perfect, but it was the smallest and most basic thing I could find. HTML Code: <html> <head> <style type="text/css"> .on {background-image:url(playlist_btn.png); background-repeat:no-repeat;} .off {background-image:url(playlist_btn_x.png); background-repeat:no-repeat;} </style> <script language="javascript"> function togglestyle(el){if(el.className == "on") {el.className="off";} else {el.className="on";}} </script> </head> <body> <div id="onoff" class="playlist_btn"><img src="blank.gif" width="50 height="50" onclick="togglestyle(onoff)"></div> </body> </html> I tested it, it worked, so I considered problem solved. I placed it in my page and nothing. Turns out it wont work with a doc type - so it's useless. Other problems, I'm not big on using "blank gif's" unless I have to, if you want multiple image toggles you need a new JS function for each one, and two lines of css as well. And, though I rarely use image rollovers anymore, it would certainly not be possible in this method. So it was back to the drawing board. Well, I had actually already found the solution a few minuets prior to finding out that the above code is so good. I had coded a button that on rollover shows a tooltip, when you click the button, the text in the tool tip, changes, chick again and it reverts. All done with a simple showHide javascript function, that i am finfing out has many uses. here is the awesome code: Code: function showHide(elementid){ if (document.getElementById(elementid).style.display == 'none'){ document.getElementById(elementid).style.display = ''; } else { document.getElementById(elementid).style.display = 'none'; } } function hideShow(elementid){ if (document.getElementById(elementid).style.display == ''){ document.getElementById(elementid).style.display = 'none'; } else { document.getElementById(elementid).style.display = ''; } } I wont take credit for the showHide code, but I will take credit for the hideShow portion, obviously a monkey could have coded the revers, but iot does make it that much more universal. As the original code was designed to show something that was hidden, add the revers to hide something that is showing and it's perfect. Now I will take a moment to say, though I have yet to find a problem with the code, it seems to work in most browsers, firefox, ie, safari, and validates for WC3 - In sure it has it's flaws. Until now, to show and hide divs I had used the MM_showHideLayers JavaScript function, which by default used the visibility style. It is of course a good script, and has many uses, it's not very big, but it is somewhat complex. The other thing to think about is that invisible objects still take up space. That's what is cool about the display:none: style, is that is not only invisible but it doesn't take up space. So here is how I used the above to JavaScript to make a simple onclick image toggle: HTML Code: <img id="on" src="on.png" width="50" height="50" onClick="javascript:hideShow('on'); javascript:showHide('off')" alt="on"> <img id="off" src="off.png" width="50" height="50" onClick="javascript:hideShow('off'); javascript:showHide('plus')" style="display:none;" alt="off"> Cool huh? Now this example does not have a rollover either, but since it uses to individual images and is not replacing one image wioth another you could easily apply a rollover to both images. But, hold on, look at the above code, isn't that essentially a rollover? Change the first onClick to onMouseOver and the second to onMouseOut and look at that a 'brand new' method for mouseovers. So lets take a look at this for a second, and compare MM_swapImage to this new hideShow method. As far as CSS rollovers I definitely prefer them to the MM_swapImage method, as they use a minimal amount of code. However they actually take a lot of math, construction the buttons is somewhat tedious, because css buttons use 1 image and change it's position, to work well you have to use a "blank.gif" and the the css can really add up if you have a lot of buttons: Also, you can't go directly to a button in the document, you have to fish through the css to make any adjustments. But they are fast, they don't need to be preloaded and... they are pretty cool. But anyway, swapImage and hideShow... The left is the MM_swapImage method. Now when you use the swapImage js you also have to use MM_swapImgRestore, MM_findObj, MM_preloadImages. You don't have to use the preload script but it does make thing work faster... supposedly, but that requires a onload script in the body tag, and if you have a lot of rollovers your body tag can get really long really quick. So what are the advantages, well we know for sure it works, and you only need on image in the document, however actualy having the image you are "swapping" too actually in the document can add functionality. So as you can see, on the right, the showHide method is, in total code, much smaller. True you do need to use two images, so the total code in the body is longer but, it's more than evened out bu the minimal JavaScript, and I think it's worth it. You don't need to use a preloader, you have full control over both images, the up and over state, and unlike the swapImage method, though it's rare you would need to, your up and over images can actually be different sizes, which is kind of cool. So here's the basic code for a rollover: HTML Code: <img id="up" src="up.png" width="50" height="50" onMouseOver="javascript:hideShow('up'); javascript:showHide('over')" alt="up"> <a href="http://google.com"><img id="over" src="over.png" width="50" height="50" onMouseOut="javascript:hideShow('over'); javascript:showHide('up')" style="display:none;" alt="over" border="0"></a> To add a link the button you just apply it to the "over state" image. And unlike swapImage, though it is overkill, you can also add a "downstate" image quite easily. So, back to the on/off button here is how you would code it using showHide with rollovers. HTML Code: <img id="on" src="on.png" width="50" height="50" onMouseOver="javascript:hideShow('on'); javascript:showHide('onover')" alt="on"> <img id="onover" src="on_over.png" width="50" height="50" onMouseOut="javascript:hideShow('onover'); javascript:showHide('on')" onClick="javascript:hideShow('onover'); javascript:showHide('offover')" style="display:none;" alt="onover"> <img id="off" src="off.png" width="50" height="50" onMouseOver="javascript:hideShow('off'); javascript:showHide('offover')" style="display:none;" alt="off"> <img id="offover" src="off_over.png" width="50" height="50" style="display:none;" onMouseout="javascript:hideShow('offover'); javascript:showHide('off')" onClick="javascript:hideShow('onover'); javascript:showHide('off')"alt="offover"> So here is what is going on: you have the upstate on.png image, when you mouse over it on.png is hidden and on_over.png is displayed. When you click on_over.png it is hidden and off_over.png is display, mouse off it and off.png is displayed. Make scene? Now be aware, when you click, you are also in a scene "mousing off" so some flickering can occur. Firefox handles everything pretty well, IE and Safari not so much. When you click the on_over.png the click tells it to hide on_over.png and show the off_over.png, at the same time the mouseoff tells it to hide on_over.png and show the on.png. So fortunately the toggle with rollovers isn't perfect, but perhaps some more tweaking of the code or maybe, in this case swapImage would work better to do the rollovers... But all in all I'd say its a solid concept. If you feel compiled to do so, reply with any comments, concerns or flaws you see. |