Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: CSS Image Map

  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSS Image Map

    I was following this tutorial in order to achieve this effect, but it's not working for me. ( http://marketingtechblog.com/2007/10/02/css-image-map/ )

    The image I'm working with is both the area where the content will go and where the links are displayed (in the image/background). The content will go in a different div layer all together, but that's not the issue here. I'm just trying to get my links working. The image is the bottom half of my layout.

    Here's the code I have.

    BTW - I am only working with the "home" link so far. The others have 0px next to them because I haven't gotten to them yet. I want one working before I try the rest.

    HTML page:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="blue.css" />
    <body>
    <body bgcolor="#FFFFFF">
    </head>
    <div id="top">
    </div>
    <div id="bottom">
    <a id="home" href="index.htm"></a>
    <a id="3dsmax" href="3dsmax.htm"></a>
    <a id="photoshop" href="photoshop.htm"></a>
    <a id="others" href="others.htm"></a>
    <div id="content">
    </div>
    </div>
    </body>
    </html>
    CSS (this is just a snippet):

    Code:
    #bottom{
    	display: block;
    	background: url(blue_bottom.jpg) no-repeat;
    	width: 689px;
    	height: 383px;
    	margin-left: auto;
    	margin-right: auto;
    	overflow: hidden;
    }
    .hide {
    	visibility: hidden;
    }
    #home {
    	float: left;
    	position: absolute;
    	width: 80px;
    	height: 24px;
    	margin-left: 15px;
    	margin-top: 169px;
    }
    #3dsmax {
    	float: left;
    	position: absolute;
    	width: 0px;
    	height: 0px;
    	margin-left: 29px;
    	margin-top: 189px;
    }
    #photoshop {
    	float: left;
    	position: absolute;
    	width: 0px;
    	height: 0px;
    	margin-left: 23px;
    	margin-top: 267px;
    }
    #others {
    	float: left;
    	position: absolute;
    	width: 0px;
    	height: 0px;
    	margin-left: 66px;
    	margin-top: 297px;
    }
    Any help would be appreciated. Thank you!
    Last edited by Aurorah; 04-07-2009 at 10:36 PM. Reason: forgot information

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello Aurorah,
    Just for starters it looks like your </head> and <body> tags are in the wrong place. Have a look at the links about validating in my sig below.

    Edit:
    You may want to have a look at this explanation of why you should avoid using absolute positioning too much.
    I have lots of menu examples here - http://nopeople.com/design/CSS%20tips/index.html - view the source to see how they work. If you see one you like, just grab it and use it.
    Last edited by Excavator; 04-07-2009 at 11:51 PM.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Maybe this is a start for you -
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    	background: #fc6;
    	font: 14px "Trebuchet MS", Arial, Helvetica, sans-serif;
    	color: #fff
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: none;
    }
    #top {
    	height: 45px;
    	background: #999;
    }
    #bottom {
    	width: 689px;
    	height: 383px;
    	margin: 0 auto;
    	background: #ccc url(blue_bottom.jpg) no-repeat;
    }
    ul#nav {
    	width: 80px;
    	margin: 50px 0 0 50px;
    	list-style: none;
    	overflow: auto;
    }
    #nav li {
    	line-height: 24px;
    }
    #home, #threedsmax, #photoshop, #others {
    	width: 80px;
    	height: 24px;
    	display: block;
    	text-decoration: none;
    }
    #home:hover, #threedsmax:hover, 
    #photoshop:hover, #others:hover {background: #FF0;}
    	#home {
    		background: #000;
    	}
    	#threedsmax {
    		background: #f00;
    	}
    	#photoshop {
    		background: #00f;
    	}
    	#others {
    		background: #0F0;
    	}
    </style>
    </head>
    <body>
        <div id="top"></div>
            <div id="bottom"> 
                <ul id="nav">
                    <li><a id="home" href="index.htm">home</a></li>
                    <li><a id="threedsmax" href="3dsmax.htm">3dsmax</a></li> 
                    <li><a id="photoshop" href="photoshop.htm">photoshop</a></li> 
                    <li><a id="others" href="others.htm">others</a></li>
                </ul>
                <div id="content"></div>
            <!--end bottom--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

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