Is there a way to have a diagonal gradient in IE? In Chrome I could do something like this:
body{
background-image:-webkit-gradient(
linear,
left top,
right bottom,
color-stop(0%,#f00),
color-stop(50%,#0f0),
color-stop(100%,#00f));
}
but this doesn't work in IE.
Yes, it is possible! Although it does not work as well as a real diagonal gradient in other browswers.
There are two important aspects of this solution that make it work:
Two divs with the same position and different z-index values (one on top of/in front of the other) and different gradient directions (one horizontal, one vertical)
Transparent/translucent colors in gradients (you can read about this in CSS3 Transparency + Gradient)
Simply place the div with the vertical gradient behind the div with the horizontal gradient (or vice-versa, it doesn't really matter), and make sure the coloring of the topmost gradient is not opaque.
The result looks like this (Internet Explorer 8):
And the CSS:
//left sample
.back
{
filter: progid:DXImageTransform.Microsoft.gradient(GradientType="0", startColorstr='#880088', endColorstr='#110011');
z-index:0;
}
.front
{
filter: progid:DXImageTransform.Microsoft.gradient(GradientType="1", startColorstr='#55ffa885', endColorstr='#55330000');
z-index:1;
}
//right sample
.diaggradientback
{
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
overflow:hidden;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType='1', startColorstr='#ffa885', endColorstr='#330000');
}
.diaggradientfront
{
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
overflow:hidden;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType='0', startColorstr='#bbffa885', endColorstr='#bb330000');
}
Update:
The documention on this filter does say that multiple filters may be applied together. However, as it turns out, applying more than one gradient filter results in only the last one being applied, so simply applying both filters to one layer doesn't work, and two layers are necessary.
The short answer is, unfortunately, no, you can't. Microsoft's gradient filter is binary - only left to right or top to bottom.
You might, however, be able to use CSS3 PIE to do what you want. Keep in mind that PIE's support for gradients in IE9 is somewhat sketchy, though, and may or may not work, even if IE7 and 8 do (see their forums for some more info).
Related
I am using vis.js and would like to align the buttons displayed when using the "navigationButtons" option to the top of the canvas.
I understand this is done using CSS, I was wondering if anyone had any examples?
Thank you in advance,
Anadi.
Preferable some HTML would be nice to work with. However you mention you'd like to update the "alignment" of the buttons. Therefore I would assume the "bottom:" and "right:" attributes is what you are looking for. However, since you want the alignment towards the top, you may want to use the "top:" attribute instead of "bottom:" and "left:" instead of "right:"...
E.g... The following should align these 4 buttons horizontally across the top... update the "left:" attribute to suit your preferred gutter width.
div.vis-network div.vis-navigation div.vis-button.vis-up {
background-image: url("...png");
top:10px;
left:50px;
}
div.vis-network div.vis-navigation div.vis-button.vis-down {
background-image: url("...png");
top:10px;
left:100px;
}
div.vis-network div.vis-navigation div.vis-button.vis-left {
background-image: url("...png");
top:10px;
left:150px;
}
div.vis-network div.vis-navigation div.vis-button.vis-right {
background-image: url("...png");
top:10px;
left:200px;
}
This bar identifies the tab below a top menu to add some color to the layout. The gradient works without the % value thrown in but what I wanted to do is stretch the solid color at the edge a bit to better define the menu. What changes should I make?
#tabLower {
background:linear-gradient(90deg,rgba(204,147,90,1) 10%,rgba(204,147,90,.5),rgba(204,147,90,1) 10%);
width:1440px;
height:10px;
position:fixed;
left:0;
top:50px;
z-index:220
}
Linear gradients are one of those anomalies. They are coded differently for different browsers. Its sometimes easier to use a generator, something like http://www.colorzilla.com/gradient-editor/
I found a cheep answer which does what i like so it fine this way. I had the opacity of the gradient at .5, I changed it to .7 and it ended up fading the color a bit slower making the edges longer.
#tabLower {
background:linear-gradient(90deg,rgba(204,147,90,1),rgba(204,147,90,.7),rgba(204,147,90,1));
width:1440px;
height:10px;
position:fixed;
left:0;
top:50px;
z-index:220;
}
I'm putting together a webpage which has a large image on the left side, and I'd like to have it seem tilted away from the viewer. I know that the transform function isn't quite capable of it. Is there a way to keystone an image using only CSS? If not, is there some extension to the language that I could safely (i.e. in a cross-browser manner) use to create this effect programmatically? For reference, keystoning as a visual effect looks like this: Keystone diagram. It is not the same thing as a skew, and it is an image distortion, rather than a crop.
It sounds like you're looking for axial rotations with perspective. Suppose that you have two nested divs, #back and #fore. The following CSS will achieve the effect. See also http://jsfiddle.net/4j8pn/6/. (In general, by the way, -webkit-transform is capable of any 3D transformation.)
#back {
margin:25px;
width:300px;
height:200px;
background-color:#555;
/* pull the viewer back; without this the div will look flat */
-webkit-perspective: 1000px;
}
#fore {
width:300px;
height:200px;
background-color:#999;
/* set origin to upper left (default is center) to get desired look */
-webkit-transform-origin: 0 0 0;
/* rotateY tilts the div like a door, rotateX tilts it like an awning */
-webkit-transform: rotateY(35deg);
}
<div id="back">
<div id="fore">
<img src="image_to_tilt.png"/>
</div>
</div>
I'd like to create an ambilight effect by using gradients.
In css3 you can let a gradient move from top to bottom, bottom to top, left to right or from right to left and you can use multiple colors. but only for one direction.
I want to combine 4 areas of an image, by calculating an average or dominant color for each area and then create a background for the image by using gradients.
I thought about using multible gradients but it would not look good when you create an gradient ac and another one bd and just place both behind the picture. (I marked the critical area.).
Do you have any Idea how this could be done?
EDIT: I don't want to mix the colors between the gradients, like in the picture. I'm satisfied with a smooth float between all colors.
EDIT2: I uploaded a demo of my problem here: http://jsfiddle.net/HJtnG/
Edit3: we've learned this can't be accomplished with CSS3 but maybe with SVG. After some reaearching I've found this picture:
So I'll go with a colored circle like the one on the picture.
In 2020, you have more possibilities to achieve what you want considering new gradients and mask.
using conic-gradient()
html {
min-height:100%;
background:conic-gradient(from 45deg,red,blue,green,yellow,red);
}
Using linear-gradient and mask:
html {
min-height:100%;
background:linear-gradient(to right,red,blue);
}
html::before {
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:linear-gradient(to right,green,gold);
-webkit-mask:linear-gradient(#fff,transparent);
mask:linear-gradient(#fff,transparent);
}
Using radial-gradient with mask
html {
background:radial-gradient(120% 120%,red 30%,#000);
}
html:before {
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:radial-gradient(120% 120%,blue 30%,#000);
-webkit-mask:linear-gradient(transparent,#fff);
mask:linear-gradient(transparent,#fff);
}
.full {
height:100vh;
position:relative;
background:radial-gradient(120% 120%,green 30%,#000);
-webkit-mask:linear-gradient(to right, transparent,#fff);
mask:linear-gradient(to right, transparent,#fff);
}
.full:before {
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:radial-gradient(120% 120%,gold 30%,#000);
-webkit-mask:linear-gradient(transparent,#fff);
mask:linear-gradient(transparent,#fff);
}
body {
margin:0;
}
<div class="full"></div>
Forgive me if I do not understand the question, but I believe what you want is a rectangular gradient. And unfortunately SVG does not support this. The closest you could get would be to have multiple linear gradients with some alpha fading out while behind that is another linear gradient fading in.
Have you tried colorzilla its free and you can do a lot of stuff with it. hope this can help.
I’m working on a site which has almost 30 background images, so I decided to make a "sprite image", and use the background-position attrib in CSS.
In FF, and Opera the whole design shows correctly, but under IE8, I get a problem. It seems IE8 doesn’t position the image correctly. I see a thin line in a few places between the images. Sometimes when I zoom in with mouse scroll the line disappears, then shows again...
For example, I use sprites something like this:
#index {
margin-left:0px;
margin-top:0px;
width:327px;
height:57px;
margin-bottom:0px;
float:left;
display:inline;
background-image:url(images/sprites/sprites_left.jpg);
background-position:0px -340px;
overflow:hidden;
}
Is this an IE8 bug? What should I do? Leave the design split into 30 background images?
Thank you.
Generally speaking I would leave a gap of a few pixels (or more) between each tile in your sprite image.