|
How do I disable a CSS anchor hover?
"Dave, I've been having great results using the hover attribute within my CSS style sheets, but when I have graphical buttons, sometimes they end up with the background-color change hover attribute as a small drop-shadow that only appears when the mouse is over the element. Y'know what I mean? How do I disable this?"
This is a classic challenge when you start working with anchor color changes within Cascading Style Sheets. It's all well and good to have a:link, a:visited, a:hover and a:active in your CSS, but typically it ends up being defined for the entire document and that's not always a desirable result. To sidestep that, you can most easily create a class that has the hover effect and apply it to the blocks where you want your tags to have this nice effect. It might look like this:
<style type="text/css" rel="stylesheet">
.hoverpink a:hover { background-color:#fcc }
</style>Then you can use it within a block of HTML by simply adding a class="hoverpink" in the div tag itself: <div class="hoverpink">
Another approach would be for you to use a CSS style that lets you define the behavior of the anchor's hover for the entire document, then override it with your images, like this: <style type="text/css" rel="stylesheet">
.nohover a:hover { background-color: transparent; }
</style>You'd use this by wrapping your img tags with either a div or span, depending on context, like this:
<div class="nohover"><a href="/ask.html"> <img src="/Graphics/marker-tray.gif" border="0" width="749" alt="whiteboard markers" height="31" /></a></div>If you view the source to this very Web page and scroll to the very bottom, you'll see this is exactly what I've done with the little marker tray graphic. That should help you change the sometimes confusing CSS anchor attributes into what you seek!
Categorized:
HTML and CSS
(Article 3781,
Written by Dave Taylor)
Tagged: Previous: How can I use Google and other Web tools to identify and research competitors? Next: How do I write a full-screen bash shell script? Subscribe!
If you choose to "disguise" a link as a non-link, you can also specify the cursor to be a nondescript arrow (default) by including '.nohover a:hover { background-color: transparent; cursor: default;}" in your style declaration. You can also disable the status bar display with javascript. I use this for a link to the database backend for my customers. Posted by: Ed Donaldson at November 29, 2005 7:57 PMSomebody has to say it! Consider onclick/active instead. A:link A[Disabled]:hover A:visited A:hover Cool! Posted by: XU at March 11, 2010 6:56 AMHello Dev Taylor, So, I want to disable the mouse over function on it . My blog address is- "http://bangladigonto.blogspot.com" . Please Visit my blog and give me a solution . -Thanks Posted by: Yadaf at April 22, 2010 3:34 PMhow to disable the status bar display of a link ?? Posted by: Seemas at September 26, 2010 6:53 AMOMG THANK YOU!!! I have been to at least 40 different sites in the last 3 days and all of there suggestions didn't work but yours does! :D my hair thanks you since it is no longer being pulled in frustration over that stupid sidebar. Posted by: Ceres at October 30, 2010 10:25 PMThanks for this tutorial; it saved me alot of headaches, made me learn more about CSS and fixed my problem, which was caused after setting up RSS to point to a set of page anchors... only to find that the a refs, that were not really links, were triggering the default hover behaviour to be applied to text that was wrapped for anchoring when they were meant to stay black in my grand design. Thanks again! Posted by: Axinar at May 8, 2011 12:44 PMYOU ARE AMAZING! I looked about 6 or 7 others websites and nothing worked but when I opened your page I fixed it in 2 minutes. Thank you] Website Coming soon I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |