Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
CSS Links - Solved
I know you can style links using CSS but can you create a link using CSS?
For example, we can place an image to the left of a heading...
For example, we can place an image to the left of a heading...
Heading
...but can we make the image clickable?Posted: Monday, 2 April 2007 at 9:11AM
0
This discussion has been closed.
Comments
that being said - there is the descriptor "content" which will let you add some content into the page via css (though i'm not sure if this would work for you)
if the image is supposed to link to the same place as the heading, why not just include the image within the tags? ie:
Heading
Posted: Monday, 2 April 2007 at 9:57AM
I have added icons to my categories and I want them to be clickable.
From a user perspective, clicking the icon is the first inclination so it's a bit annoying when nothing happens.
Posted: Monday, 2 April 2007 at 10:34AM
h1:before { content: '<a href="http://example.com/">Link</a>'}
would just result in you getting<a href="http://example.com/">Link</a>
added before your h1 element contents (in plain text).Also, it wouldn't surprise me if there is little or no support for the content rule in IE.
@Wanderer -
you might try doing something like this in the CSS:
ol#Categories li#Category_4 a { background: url(categoryicon.gif) left top no-repeat; padding-left: 32px; }
repeat that as needed for the other categories. then just match up the appropriate category IDs with the right images, and it should be okay, i think. this way, the image is technically part of the background to the link itself, and should be clickable.
that code might not be perfect, i'm a little sleepy, but you get the idea.
I'll keep working on it.
Posted: Monday, 2 April 2007 at 3:46PM
<img src="bla" />
as part of the category name? or some such nice hackedit: @Wanderer: This was for you. I looked at your site and saw that.
Give this a shot: (add it to your existing stylesheet--and remove the existing category4 reference to the same icon)
#CategoryPage #Category_4 .CategoryName a { padding-bottom: 45px; background: url('icons/cat.podcast.gif') 0 20px no-repeat; }
Only downside would be if someone increases the font size above 20 px, then it will overlap the icon... In retrospect if you use ems instead of px that would fix it.
position: relative; z-index: 4;
Posted: Tuesday, 3 April 2007 at 7:35AM
However, although I tweaked WallPhone's method to get it to look right, on the Discussions page the icons don't link... yet.
Posted: Tuesday, 3 April 2007 at 8:33AM
At one stage, I thought it was working, I had the icon appearing twice on top of itself, once for the categories page and again for the Discussion Overview. I never thought I'd thank IE but it, of course, rendered the icons offset by a couple of pixels and they looked ugly so I went back to the drawing board with a fresh approach.
I have put the jigsaw pieces together and with lots of problem-solving, tenacity and some sheer luck I have managed to unravel the puzzle and made it work.
Thanks again peeples.
Posted: Tuesday, 3 April 2007 at 3:37PM
only thing that would annoy me is that some areas that are not part of the icon/link are also clickable, which would drive me bonkers
If you are referring to the extra width, the clickable width is actually the width of the category title, that's where the <a> tag lives so I didn't have much choice, other than shortening the category title name.
If you live in New York, I think the trip to Bonkers is a short one.
Posted: Tuesday, 3 April 2007 at 4:07PM