Fade background with transparent curtain - html

It is quite popular question, I think.
I am looking for crossbrowser CSS solution for black opaque layer. Which will hide all stuff under it.
My example: http://jsfiddle.net/pb9jv/. But it is not crossbrowser. (IE 6+ is the pain in my ass).

Try adding this the the CSS style you apply to the fadeover (In your example : #black)
filter: alpha(opacity = 50);
EDIT : You want it to be opaque or transparent like the given example?
Have a look at this, it does work on IE 6

Use a simple div and apply a background-image to it with a 1px size image of your color. Just a simple png with your black color.
.overlay
{
background-image:url('myoverlaycolor.png');
}
It will repeat itself across the complete div.
Edit
Come to think of it, IE6 doesn't support png right? Maybe you could just take a look in sources like slimbox.

David is right - that is the syntax.
However your fiddle will not work in IE6 since you have no size values.
Here is an example:
http://jsfiddle.net/4Aw4Q/
If you remove the sizing the element will not show.

#Marnix If you use proper filters IE6 does support PNG. Try this for starters
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/pngimage.png', sizingMethod='scale');
Set the above filter in as a class for the span or div element containing the image and make sure the width and the height of the image are set.
Set this class also for the span or div element containing the image.
.PNGTrans img{
background: transparent;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
}
So the above to classes will have to be called for the parent containing the png image.
#fl00r : Have a div element with higher z-index with screen.width and screen.height as its widht and height respectively. You can either use an image or you can play with opacity filters.

Related

Force/3dTouch gesture on iphone gives weird background for <a> element

I have button which is <a> element with href, which doesnt have any background set on :active/:focus/:visited, but on force/3dTouch tap it gets this weird #b8b8bc background under the text only (while <a> doesnt have any children e.g. <span> etc so I suppose this is the text node highlight).
here's the gif to illustrate the behavior.
I've tried adding -webkit-tap-highlight-color: transparent but it changes only regular tap color, not the forced/3d one
also I thought maybe that's selection color (as I can reproduce this on various websites) so tried to use selection selectors which didn't help as well
::selection {
background: transparent;
}
::-webkit-selection {
background: transparent;
}
::-moz-selection {
background: transparent;
}
Any ideas about possible origin of this?
Good job digging up.
I had the same issue plus another one and here are my solutions.
Post is old but someone could find it useful like me today.
First of all, the forced background was covering my link text totally because I was using user-select: none; on my header links.
So that's something to check, just in case.
Regarding the background color, Force Touch doesn't use the link parent element background but the one that's under it.
If you want to "feel it", we could say that Forced Touch digs into the direct parent background and let the under layer appears.
So, to counter that without having to touch to background color, I use some z-index in the parent element to elevate it, preventing Forced Touch to "dig" :)
So if your links parent element is named card, you can add to your CSS:
.card {
isolation: isolate;
z-index:1;
}
Now, Force Touch will use the parent background color as we want to.
Okay so I found sort of "solution" based on parent's color.
Try to set *{background: red}.
If worked try set same on few parents .parent1 { background: pink}, .parent2 { background: lightblue}, .parent1 { background: salmon} etc.
In my case I found the color applied to force touched text was menu wrapper's background that takes most of the screen when menu is opened.
Side effect of this change - all forcetouched elements will have same color, no option to specify :hover or :active colors (you can see the color is slightly different on the 1st click) and ALL links will have same background:
I imagine you can try setting wrapper's background via JS based on what is clicked. Not sure if that will work. see docs here:
WebKit DOM Programming Topics
So far this seems to me too fragile to touch and I would not recommend doing this. Though you can change this color I've decided to let OS do what it wants here.

Color overlay on shape

I've got a small problem.
I want to create an overlay effect on the picture in the following jsfiddle.
http://jsfiddle.net/39gud4bh/1/
<div>
<img id="bubble" src="http://png-1.findicons.com/files/icons/2711/free_icons_for_windows8_metro/128/speech_bubble.png">
<img src="http://s30.postimg.org/lptvfyod9/speech_bubbleorange.png">
</img>
</div>
#bubble {
}
I want the overlay to have the color #ff9f2d
How is this possible? Been trying litterally everything i could find. The problem is that the image (might not be in jsfiddle) is a shape with a transparent background. This causes all my attempts to background/foreground filter the color to recolor the whole square instead of just the shape.
Really need some help.
In advance - Thank you!
EDIT - Fiddle has been updated to entail the desired outcome of the CSS on the grey bubble.
I don't think you can turn that yellow bubble into gray one with just css.
You could do that if you reversed transparent and colored parts, and filled whole square with color. Example: http://jsfiddle.net/Arministrator/j5gLgyt8/
#bubble_img{
background:yellow;
}
#bubble_img:hover{
background:#ff9f2d;
Or you can use two images (css sprites even better) as shown in one of the answers.
This may not be the exact answer you're looking for, but maybe you can consider using Font Awesome. It'll be a clean, sharp bubble and you can easily resize and color it anyway you want with CSS. Another route would be to use SVG.
http://jsfiddle.net/wilchow/39gud4bh/5/
.fa-bubble {
font-size: 140px;
color: #333333;
cursor: pointer;
}
.fa-bubble:hover {
color: #ff9f2d;
}
Just move the second image over the first and set opacity
#overlay {z-index:100;opacity:0.2;position:relative;left:-131px;top:-3px;
}
<div>
<img id="bubble" src="http://png-1.findicons.com/files/icons/2711/free_icons_for_windows8_metro/128/speech_bubble.png">
</img>
<img id="overlay" src="http://s30.postimg.org/lptvfyod9/speech_bubbleorange.png">
</div>
As far as I know there is no CSS property that will allow you change a gray colored image into a colored one.
However, the reverse is possible using CSS filters.
So if we reverse the 'process' and make the colored image appear grey by default we can remove that styling, perhaps on hover, to achieve the effect we are looking for.
#bubble {
-webkit-filter: grayscale(1) brightness(0.3);
}
#bubble:hover {
-webkit-filter: none
}
<div>
<img id="bubble" src="http://s30.postimg.org/lptvfyod9/speech_bubbleorange.png" />
</div>
Jsfiddle Comparison
NOTE: CSS filters are highly experimental and browser support is poor.
This is an experimental technology
Because this technology's
specification has not stabilized, check the compatibility table for
the proper prefixes to use in various browsers. Also note that the
syntax and behavior of an experimental technology is subject to change
in future versions of browsers as the spec changes
MDN Reference
CanIUse.com Reference

How to set an input's background transparency?

input[type="text"], input[type="password"]{
opacity:0.5;
}
This fades both - input body and border. I don't want border transparent, just body, so the underlying image is visible. User-text inside the input should not be transparent, of course.
input [type="submit"]{
margin-left:50px; // here nothing works at all.
}
The opacity property influences the opacity of the whole element. Your question is bit vague, but I assume that you want to have a semi-transparent background, while the content and borders shouldn't have transparency.
To do so, you need to set a semi-transparent background to the element. This is called alpha-transparency, as a fourth color channel - the alpha channel - is used to store the transparency information (usually in an image like a PNG).
In modern browsers you could use the rgba() value for the background property:
/* semi-transparent white background */
background: rgba( 255, 255, 255, .5 );
In MS IE you could use a gradient filter, which supports ARGB colors since MS IE 5. Just fade from a color to itself: (be aware, that the alpha channel comes first and all four color values are noted as two-digit hexadecimals)
/* the same for IE 7+8, should get included in a separate MS IE specific stylesheet */
background: none;
zoom: 1;
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=#E5FFFFFF, endColorstr=#E5FFFFFF );
-ms-filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=#E5FFFFFF, endColorstr=#E5FFFFFF );
Opacity works on the whole text input including the text inside it. So your code won't work.
Option 1) Can you use CSS3? If so, use (with the color you want, of course):
background-color: rgba(255,0,0,0.5);
Option 2) You can set the background of the Input as the image you want to see.
Option 3) You can set the background as a semi-transparent solid color image (.gif/.png, which can be 1x1 in size and repeated in X and Y).
For the submit, you need to get rid of the space in your selector:
input[type="submit"]{
margin-left:50px;
}​
And you can't specify what parts of the element you want to make transparent with opacity. It applies to err'thang. There might be 'hacks' of sorts to achieve what you want, such as using a wrapping div to create the border.

Opacity only at a particular area

I want to give opacity for the div only at the bottom left corner.
Is it possible? how?
<div id="right_img"></div>
css
#right_img
{
float:right;
width:600px;
height:400px;
margin-top:100px;
background:url(../images/assets/sobrf-maria-page.jpg) no-repeat bottom center;
opacity:0.6;
filter:alpha(opacity=60);
}
If I give opacity to the complete div, image clarity will be lost.
Use a PNG image instead and make the transparency part of the image?
Giving Opacity to an element always affects the whole element and all of its child-elements too. If you want to give only one of it's children the opacity property, you have to declare it directly on that element. Sometimes you have to introduce some helper Elements to achieve the effect you want.
Exception is the opacity you declare on colors which don't get inherited to the child elements. With the new rgba() declaration, (the fourth parameter is the opacity of the color), you can achieve effect like having a "transparent" div (transparent background) but the font is completely opaque.
In your case it might be sufficient (interpreting your answer - it wasn't quite clear) to just use the normal background-declaration with this rgba background-color:
#right_img{
background:rgba(x,y,z,0.6) url(../images/assets/sobrf-maria-page.jpg) no-repeat bottom center;
}
with x,y,z = 0...255 and a = 0...1
Note, that the rgba() declaration is not supported in older IEs (even IE8!). You need a filter to support these. Luckily there is one:
filter:progid:DXImageTransform.Microsoft.gradient(
startColorstr=#aaxxyyzz,
endColorstr =#aaxxyyzz);
where the first parameter (a) is the opacity with 0% = 00 and 100% = FF. And xx,yy,zz = 00...FF.

Opacity in css for individual tags

I am using the following css to make all items in the main DIV of my page to be transparented:
#wrapper
{
filter:alpha(opacity=90);
-moz-opacity: 0.9;
opacity: 0.9;
}
This works and everything gets transparented. But for example I DO NOT want the texts, images and buttons to be transparented. How can I do this?
You can do this like so:
#wrapper{
color:rgba(255,255,255,0.9);
}
You will have to use rgba() to achieve this. Take a look at this website:
http://www.css3.info/introduction-opacity-rgba/
I did also come over this problematic and solving it with rgba() is really the best way to get around this. Using transparent images as background, in my opinion is not as flexible as it should be and I'm really against using images when you can achieve the effects you want in other simpler ways.
You need to use a transparent background (in png) for your wrapper and do not use opacity
The child-elements inherit the opacity and you can not directly change it back. But there is a workaround http://www.impressivewebs.com/css-opacity-that-doesnt-affect-child-elements/