Web Analytics Made Easy -
StatCounter CSS Image Map - CodingForum

Announcement

Collapse
No announcement yet.

CSS Image Map

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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; Apr 7, 2009, 05:36 PM. Reason: forgot information

  • #2
    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; Apr 7, 2009, 06:51 PM.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use a DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

    Comment


    • #3
      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 a DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

      Comment

      Working...
      X