Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-17-2012, 02:48 PM   PM User | #1
shivup
New Coder

 
Join Date: Aug 2012
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
shivup is an unknown quantity at this point
Set hyperlink to image class??

Hello Guys,

Is there any way I can set hyperlink to a image which is in image class in css?

for ex.
I have this

<div class="thumbnail"><a href="/test/test1.php"><img src="/images/covers/test.jpg" alt="test" class="bkmrk" /></a>

and here is my css file

.thumbnail {
float: left;
width: 20%;
text-align: center;
margin-bottom: 20px;
}

.thumbnail img {
height: auto;
width: 95%;
max-width: 150px;
padding-top: 20px;
}

.thumbnail .bkmrk {
background: url(/images/gold-bookmark.png) no-repeat 15px top;
}

and my output is



is there any way I can set an hyperlink to this gold-bookmark.png image.. when i click on gold-bookmark.png it should take me somewhere and when i click on actual test.jpg it should take me to /test/test.php.. It seems impossible to me.. let me know if you have any solutions how to do it.. I am willing to do any necessary changes since output will be the way I want..


thank you
shivup is offline   Reply With Quote
Old 08-17-2012, 03:51 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,584
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
You need two different links for that. From where do you think would the browser get the URL to go to?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 08-17-2012, 05:33 PM   PM User | #3
shivup
New Coder

 
Join Date: Aug 2012
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
shivup is an unknown quantity at this point
Quote:
Originally Posted by VIPStephan View Post
You need two different links for that. From where do you think would the browser get the URL to go to?
hello,
I do have two different links.. lets assume, second link is http://www.google.com, when i click on that flag on top.. (gold-bookmark.png) it should take me to google.com

is there any way to do it??

Thanx
shivup is offline   Reply With Quote
Old 08-18-2012, 12:14 AM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,584
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Code:
<div class="thumbnail">
  <a class="bookmark" href="http://example.com">Bookmark</a>
  <a href="/test/test1.php"><img src="/images/covers/test.jpg" alt="test" class="bkmrk" /></a>
</div>
Code:
.thumbnail {
  float: left;
  width: 20%;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  padding-top: 20px;
}
.thumbnail .bookmark {
  position: absolute;
  background: url(/images/gold-bookmark.png) no-repeat 15px top;
  top: -20px;
  left: 15px;
  width: 20px;
  height: 20px;
  text-indent: -999em;
}
.thumbnail img {
  height: auto;
  width: 95%;
  max-width: 150px;
}
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
shivup (08-18-2012)
Old 08-18-2012, 03:07 AM   PM User | #5
shivup
New Coder

 
Join Date: Aug 2012
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
shivup is an unknown quantity at this point
Quote:
Originally Posted by VIPStephan View Post
Code:
<div class="thumbnail">
  <a class="bookmark" href="http://example.com">Bookmark</a>
  <a href="/test/test1.php"><img src="/images/covers/test.jpg" alt="test" class="bkmrk" /></a>
</div>
Code:
.thumbnail {
  float: left;
  width: 20%;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  padding-top: 20px;
}
.thumbnail .bookmark {
  position: absolute;
  background: url(/images/gold-bookmark.png) no-repeat 15px top;
  top: -20px;
  left: 15px;
  width: 20px;
  height: 20px;
  text-indent: -999em;
}
.thumbnail img {
  height: auto;
  width: 95%;
  max-width: 150px;
}
Man, You are genius.. you made my day.. thank you buddy... great help
shivup is offline   Reply With Quote
Reply

Bookmarks

Tags
class, css, html, hyperlink

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:47 PM.


Advertisement
Log in to turn off these ads.