Opacity not working on img in IE8 - css

I have code that works in Chrome and Firefox, but not in IE8.
<a href="javascript:void();" class="shareActionLink" id="comment">
<img src="comment.gif" class="shareActionImage" />Comment
</a>
The CSS for this is:
.shareActionLink:link, .shareActionLink:visited
{
margin-right:8px;
color:#999;
opacity:0.6;
filter: alpha(opacity=60); /* internet explorer */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=60)"; /*IE8*/
background-color: #fff;
}
#shareActionsBox .shareActionLink:hover
{
color:#333;
text-decoration:none;
opacity:1.0;
filter: alpha(opacity=100); /* internet explorer */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=100)"; /*IE8*/
}
Based on other StackOverflow posts, I added the IE filters, which helped to adjust the text opacity, however, the image opacity still doesn't change in IE. It works fine in other browsers.
I suspect that this is happening because the img is nested within the link. How do I get the image to change opacity in IE??
Thanks

MS filters only work in IE7 if the hasLayout property is set to true, they only work in IE8 on block elements, or if you set the display property to block or inline-block.. as you're trying to use this on an inline element, the a, then setting display: inline-block; should solve it for all IE's as it works to set hasLayout for IE7 and also keeps IE8 happy
.shareActionLink {
display: inline-block; /* IE needs but shouldn't hurt anyone else */
}
.shareActionLink:link, .shareActionLink:visited {
margin-right:8px;
background: #fff;
color:#999;
opacity:0.6;
filter: alpha(opacity=60); /* IE */
}
.shareActionLink:hover {
color:#333;
text-decoration:none;
opacity:1.0;
filter: alpha(opacity=100); /* IE */
}

Off the top of my head, setting opacity on a parent element means it's children elements get, erm, opacitied? as well.
To target the image specifically, add img after each of the css selectors; e.g.:
#shareActionsBox .shareActionLink:hover img
to target the image whenever the parent link is something (in this case when hovered).

I could not get this to work in IE6 without targeting the <img> element. I've not got IE8 installed so cannot be sure this demo will work in that browser. However, it does work in IE6, Chrome11 and Firefox4.
Also, it is worth noting that if your comment.gif has transparency then you may have further problems with the transparent part unless you set a background-color or use JavaScript to handle the hover. See another answer I wrote on this.

Related

Opacity transition for a:hover not working

I want all elements that are links to show consistent behavior.
a:hover { opacity: 0.5; }
This works in IE and Firefox, but the opacity (and associated CSS transition) is not properly applied to the child elements of the <a> tag in Chrome and Safari. If I add an explicit rule for a <div> as a child element, it works in Chrome and Safari:
a:hover, a:hover div { opacity: 0.5; }
So far so good, and this has been asked and answered before. The problem that I have is that by adding the rule for the containing <div>, the opacity gets applied twice in IE and Firefox, making the element too transparent.
I need to cover both scenarios - <a> wrapping a <div> or not, without writing lots of explicit CSS rules. How can I do that?
http://liveweave.com/fMsz7m
What worked for me in Safari was adding display: block into the a tag
a:hover {
opacity: 0.5;
transition: opacity 0.2s ease;
display: block;
}
I'm not sure whether this counts as a direct solution to your question (I'm not sure why the children aren't inheriting), but you can add display: block to the a in your css which will work (tested with Firefox and Chrome).
JSFiddle DEMO
An alternative is to assign the hover to your <div>, parent of <a>.
JSFiddle DEMO
I feel as though there are better solutions/explanations out there, maybe this one will spark an idea for someone else.

What does it mean by '-moz-transform' depricated?

I have used the CSS below to make speech bubble for my website, Yep Website
It looks okay in google chrome and safari. It does not show up in firefox giving me, '-moz-transform' depricated? I am not good in designing. I want to seek help how to correct this problem. Thanks in advance.
/*SPEECH BUBBLES*/
.wiget_bottom_all li h3 {
position:relative;
padding:15px;
margin:1em 0 3em;
color:#fff;
background:#00B9B7;
/* css3 */
background:-webkit-gradient(linear, 0 0, 0 100%, from(#f04349), to(#c81e2b));
background:-moz-linear-gradient(#f04349, #c81e2b);
background:-o-linear-gradient(#f04349, #c81e2b);
background:linear-gradient(#00B9B7, #00B9B7);
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
}
/* THE TRIANGLE
------------------------------------------------------------------------------------------------------------------------------- */
/* creates the wider right-angled triangle */
.wiget_bottom_all li h3:before {
content:"";
position:absolute;
bottom:-20px; /* value = - border-top-width - border-bottom-width */
left:105px; /* controls horizontal position */
border:0;
border-right-width:30px; /* vary this value to change the angle of the vertex */
border-bottom-width:20px; /* vary this value to change the height of the triangle. must be equal to the corresponding value in :after */
border-style:solid;
border-color:transparent #00B9B7;
/* reduce the damage in FF3.0 */
display:block;
width:0;
}
Firefox has probably stopped to support the vendor prefixed css rule.
Do you have a not vendored prefixed css rule: transform: ... that will probably do the trick.
According to http://caniuse.com/#search=transform the not vendored prefixed transform rule has been supported in firefox since firefox 19.
edit: You do not use -moz-transform in your example code on s.t. you probably use it somewhere else in your css otherwise the error message really should not be there
Seems to have issues with cross browser codes. You can refer to css tricks for cross browser compatible codes. Perhaps, read this.

IE <= 9 pseudo element inherits container style when container is hovered

See this jsfiddle for a working example of the problem.
Opera 12, chrome, and firefox all work as intended, while IE9 and below underline the pseudo element.
I have already tried the following:
a:hover *,
a:before,
a:hover:before {
text-decoration: none;
}
but neither selectors work.
Finally managed to find an (half decent) way to handle IE:
clip: rect(0px 300px 16px 0px);
This hides the underline while leaving everything else - also updated the jsfiddle

How do I remove parent opacity in CSS?

In my CSS I have the following:
.Thing {
filter: alpha(opacity=40);
opacity:0.4;
-moz-opacity:0.4;
}
.Thing button {
filter: alpha(opacity=100);
opacity:1;
-moz-opacity:1.0;
}
However, the button is still .4 opacity. I then try opacity: 2 and such and it looks like I can give it less opacity but not more. Is there a way I can remove it or do I have to write multiple rules to get everything but the button?
I am testing with Firefox and Chrome.
use rgba with a rgb fallback.
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.5); /*ie6 will ignore this*/
rgba will only apply opacity to the target element.
What i've recently been doing is using the rgbapng sass/compass plugin which generates a png image to use as a fallback for browsers without rgba support.
Note: you'll still need to use an ie6 png fix for this to work.
Not a fix for the opacity issue but a possible workaround.
How about removing the button from the normal document flow and then placing back inside the .Thing
Something like this: http://jsfiddle.net/CqgkM/

CSS: Styling visited images cross browser way / cross browser opacity

I want to use the CSS visited functionality in the browser to style a clicked image:
CSS:
.gridview a.plusminus:visited img
{
/* from http://my.opera.com/BleedingHeart/blog/2007/04/29/highlighting-visited-images-using-css */
background: transparent !important;
opacity: 0.2 !important;
}
HTML:
<a class="plusminus" href="#12345" onclick="/* code to exand a panel*/" onfocus="this.blur();">
<img title="Expandera" src="img/grid_plus.gif" width="14" height="14"/>
</a>
This works fine in Firefox 3.5.
But for i.e. Explorer the opacity/transparent trick don't work. Is there a way that I can do this cross-browser?
Also explorer seems not to remember "#12345" type of hrefs for visited links when reloading pages. Any way to fix that?
for opacity:
.gridview a.plusminus:visited img {
-moz-opacity: 0.2; filter:alpha(opacity=20); opacity: 0.2;
}
sorry don't know about remembering of anchor refs (but as I know they should work)
.gridview a.plusminus:visited img {
opacity: 0.2;
-ms-filter: "alpha(opacity=20)"; /* IE 8 */
filter: alpha(opacity=20); /* IE 4-7 */
}

Resources