rh-penguin Posted April 25, 2007 Share Posted April 25, 2007 hi, Can someone please tell me howto link a image(inserted within css) to some location? (ex. I press over an image and it takes me to index.php) Thanks Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/ Share on other sites More sharing options...
marmite Posted April 25, 2007 Share Posted April 25, 2007 You want to use a CSS image as a link? I believe you'd still need to use <a href within the code. CSS images are like html wallpaper - you can't click on them. The following article talks about css rollovers and as you can see, you refer to the CSS in a div, but still need the <a href to actually make the link. http://www.webcredible.co.uk/user-friendly-resources/css/rollover-buttons.shtml Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/#findComment-238550 Share on other sites More sharing options...
rh-penguin Posted April 26, 2007 Author Share Posted April 26, 2007 Quote you refer to the CSS in a div, but still need the <a href to actually make the link. I've did that but something dont seem to work right. Okay..... I've got a header.php. Inside theres a logo and a few other things(login, register LINKS etc.....). My css for the logo is as following: #logo { background-image:url(images/logo.png); width: 151px; height: 65px; margin-top: 18px; margin-left: 35px; } and then i display it with HTML like: <a href="index.php"><div id="logo"></div></a> I've specifid the width and height of the logo(as you can see) BUT when i go to view this in a browser and if i hover over the logo, instead of making ONLY the logo a link, the div take all the space to the right. So instead of the width being 151px(for the link) it makes it something like 800px. Have i done something wrong? I hope i didnt confuse you, i was getting confused my self..... Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/#findComment-239024 Share on other sites More sharing options...
brown2005 Posted April 26, 2007 Share Posted April 26, 2007 not on mine.. what code u got around the <a> Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/#findComment-239062 Share on other sites More sharing options...
ToonMariner Posted April 26, 2007 Share Posted April 26, 2007 a has to have display: block adn correct height and width. Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/#findComment-239073 Share on other sites More sharing options...
rh-penguin Posted April 26, 2007 Author Share Posted April 26, 2007 what do you mean by a? you talking about a href(the link)? The image is already inserted inside css(background-image:images/bg.ong;) Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/#findComment-239410 Share on other sites More sharing options...
ToonMariner Posted April 27, 2007 Share Posted April 27, 2007 yes i mean the href the <a> tag has to have display:block; too... Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/#findComment-239481 Share on other sites More sharing options...
rh-penguin Posted April 29, 2007 Author Share Posted April 29, 2007 ok, its working as i want now. Thanks! Link to comment https://forums.phpfreaks.com/topic/48679-solved-howto-make-a-link-inside-a-css-file/#findComment-240997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.