How do I "stop" a gradient from flowing further down the page? - css

I think the easiest way to explain is simply linking to an example of what I want:
http://macrumors.com
At the top there's a small blue gradient that doesn't stretch very far.
I want to replicate this, but the only way I know how to do gradients in CSS3 is from top to bottom of the page, not stopping midway through. I looked around and couldn't really find anything, though I did see color-stop property, but I'm not sure if that's what I'm looking for.
Could anyone give me a hand?

#test {
background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(top, #1e5799 0%, #e2e2e2 10px); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100px,#e2e2e2)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #1e5799 0%,#e2e2e2 100px); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #1e5799 0%,#e2e2e2 100px); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #1e5799 0%,#e2e2e2 100px); /* IE10+ */
background: linear-gradient(top, #1e5799 0%,#e2e2e2 100px); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#e2e2e2',GradientType=0 ); /* IE6-9 */
​}​
I have no idea what blue and hight is used on that background image, but you can easily insert in into code pasted above. Demo: http://jsfiddle.net/xyn4f/
You should also check online gradient generators. I used that one to generate the code.

Related

Gradient Background

Hi guys i am making a website for my college project and i am not very good at using Dreamweaver CS6. I made my designs in photoshop and i am struggling to use my gradient background in my website. I have tried a couple of times to get it to work but it either repeats a lot of times or it fills up as certain amount of the page but cuts off. Any help would be appreciated thank you in advance.
Here is the CSS code
html body
{
background: linear-gradient(to top, #48E7A2 0%, #86C4ED 100%);
background-size:cover;
}
You can copy this code. From http://www.colorzilla.com/gradient-editor/
You should use it on the html{} not on the body{}
and add height:100%;
html {
height: 100%;
background: #48e7a2; /* Old browsers */
background: -moz-linear-gradient(top, #48e7a2 0%, #86c4ed 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#48e7a2), color-stop(100%,#86c4ed)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #48e7a2 0%,#86c4ed 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #48e7a2 0%,#86c4ed 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #48e7a2 0%,#86c4ed 100%); /* IE10+ */
background: linear-gradient(to bottom, #48e7a2 0%,#86c4ed 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#48e7a2', endColorstr='#86c4ed',GradientType=0 ); /* IE6-9 */
}
DEMO

Height set to 100% yet page not rendering properly

Here's a link to my page: http://mobile.sheridanc.on.ca/~vecanski/
The problem that I am having is that height is set to 100% and yet i can still scroll down and see the light blue, even though there is nothing on the page except floating bubbles. Does anyone knows as to why I am able to scroll down? Also I have a gradient effect, here is the code:
background: #4094d1; /* Old browsers */
background: #4a97ce; /* Old browsers */
background: -moz-linear-gradient(top, #4a97ce 0%, #2687cc 22%, #1080cc 48%, #0c0c02 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4a97ce), color-stop(22%,#2687cc), color-stop(48%,#1080cc), color-stop(99%,#0c0c02)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #4a97ce 0%,#2687cc 22%,#1080cc 48%,#0c0c02 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #4a97ce 0%,#2687cc 22%,#1080cc 48%,#0c0c02 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #4a97ce 0%,#2687cc 22%,#1080cc 48%,#0c0c02 99%); /* IE10+ */
background: linear-gradient(to bottom, #4a97ce 0%,#2687cc 22%,#1080cc 48%,#0c0c02 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4a97ce', endColorstr='#0c0c02',GradientType=0 ); /* IE6-9 */
What I don't understand is why does the gradient not go all the way, even if it is scrollable, why does it restart at the end of the page?
So 2 questions really:
How do I remove the scroll-able part of the page?
If I were to leave the scroll-able part of the page in, how do I force the gradient to extend to the very end and not restart?
you can figure out the problems like this by using browser inspect element
by the way, to fix this:
Remove #bubbles padding:100px 0
OR
Add overflow:hidden to the #container

CSS changing colors in different browsers

I am experiencing a somewhat weird bug on a website I am building.
Using Chrome/Firefox/Safari/IE10 it works fine. However, using IE9 it turns into blue! What is wrong?
I suspect this code is messing it up (#colorOne, #colorTwo is replaced by the actual colors):
.gradient (#colorOne, #colorTwo) {
background: #colorOne; /* Old browsers */
background: -moz-linear-gradient(top, #colorOne 0%, #colorTwo 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#colorOne), color-stop(100%,#colorTwo)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #colorOne 0%,#colorTwo 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #colorOne 0%,#colorTwo 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #colorOne 0%,#colorTwo 100%); /* IE10+ */
background: linear-gradient(to bottom, #colorOne 0%,#colorTwo 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#colorOne', endColorstr='#colorTwo',GradientType=0 ); /* IE6-9 */
}
You have a blue Microsoft filter gradient in your CSS on the #top element and other elements within your site. But since you're specifically asking about the header, just remove:
#top {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#colorOne', endColorstr='#colorThree', GradientType=1);
/* Remove this from any other element you wish to be green */
}
The only difference is a gradient only interpreted by IE:
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#colorOne', endColorstr='#colorThree', GradientType=1
Simply remove it.

Convert linear gradient from Mozilla to Chrome

I am having some problems converting a linear gradient for viewing in Chrome. It would be a bonus to see this gradient for full cross-browser too if you're willing, I'm developing a theme and it would help tremendously.
Here's the Mozilla version here:
background:
-moz-linear-gradient(center bottom , #401746 0%, rgb(255, 255, 255) 250%) repeat scroll 0% 0% #6e2778;
Go to http://www.colorzilla.com/gradient-editor/, import gradient, this is what you get. I do wonder how that %250 stop location would be handled cross browser, though. It might not strictly be valid across browsers.
background: #401746; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzQwMTc0NiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjI1MCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #401746 0%, #ffffff 250%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#401746), color-stop(250%,#ffffff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #401746 0%,#ffffff 250%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #401746 0%,#ffffff 250%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #401746 0%,#ffffff 250%); /* IE10+ */
background: linear-gradient(to bottom, #401746 0%,#ffffff 250%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#401746', endColorstr='#ffffff',GradientType=0 ); /* IE6-8 */
Edit: Nevermind about my color stop worries (see http://dev.w3.org/csswg/css3-images/, section 4.1.1. linear-gradient() syntax, second to last paragraph):
The gradient's color stops are typically placed between the starting point and ending point on the gradient line, but this isn't required - the gradient line extends infinitely in both directions. The starting point and ending point are merely arbitrary location markers - the starting point defines where 0%, 0px, etc are located when specifying color-stops, and the ending point defines where 100% is located. Color-stops are allowed to have positions before 0% or after 100%.
Emphasis, my own.

linear-gradient equivalent to moz-linear-gradient

I want to replace the following Mozilla-specific CSS rule:
background: -moz-linear-gradient(center top , #F5F5F5, #E4E4E4);
with an equivalent rule that uses the standard linear-gradient instead. In other words, how can I complete the following rule so that it has the same effect (in Firefox) as the rule above
background: linear-gradient /* what goes here? */
This is how I handle all gradients for all browsers, I hope this helps;
background: -moz-linear-gradient(top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* IE10+ */
background: linear-gradient(top, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000',GradientType=0 ); /* IE6-9 */
You could also use some gradient generators if you are having some difficulties or just for speeding up the process.
Examples:
http://www.colorzilla.com/gradient-editor/
http://westciv.com/tools/gradients/
http://gradients.glrzad.com/
center is not part of the linear gradient specification. (I don't know why it's ignored rather than being a CSS error.) The most up-to-date syntax supported by Firefox is -moz-linear-gradient(to bottom, #F5F5F5, #E4E4E4); however as far as I know the specification hasn't reached CR status so this could still change.

Resources