ksander314
ksander314

Reputation: 13

css linear-gradient in chrome

I try to get a vertical red line over screen in background, like this. In firefox it works properly, but in chrome 31 red line is lost.

My css code:

html {
    background-image:
    linear-gradient(90deg, transparent 6em, red 6.2em, red 6em, transparent 6.2em),
    linear-gradient(#eee .1em, transparent .1em);
    background-size: 100% 1.2em;
}

Appreciate your help.

Upvotes: 1

Views: 3896

Answers (3)

G-Cyrillus
G-Cyrillus

Reputation: 105893

maybe if

you use latest syntaxe

fill all areas with colors (and use rgb instead of transparent, just because i like it better )

use bakground ssize for the 2 linear gradient,

it should work fine :)

http://codepen.io/anon/pen/fpkHE

html {
  background:
    linear-gradient(to right,
      rgba(0,0,0,0) 0,
    rgba(0,0,0,0) 6em, 
    red 6em , 
    red 6.2em ,
    rgba(0,0,0,0) 6.2em,
    rgba(0,0,0,0) 
    ) top left,
    linear-gradient(to bottom,
      #eee .1em, 
      transparent .1em) top ;
  background-size: auto auto ,  100% 1.2em;
  height:100%;/* for test in empty page */
  width:100%;

}

Upvotes: 0

Ashley Medway
Ashley Medway

Reputation: 7301

linear-gradient is one of the many CSS3 properties what needs to be vendor specified.
At least in the current browsers of February 2014.

A great website for generating CSS3 gradient with lots of cross-browswer support. HERE.

Example Cross-Browser Support

background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(top,  #1e5799 0%, #7db9e8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #1e5799 0%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #1e5799 0%,#7db9e8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #1e5799 0%,#7db9e8 100%); /* IE10+ */
background: linear-gradient(to bottom,  #1e5799 0%,#7db9e8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */

Upvotes: 1

Khrone
Khrone

Reputation: 11

Try add "-webkit-" to those "linear-gradient" prefix for compatibility with Chrome, as is described here:

-webkit-linear-gradient(90deg, transparent 6em, red 6.2em, red 6em, transparent 6.2em),
-webkit-linear-gradient(#eee .1em, transparent .1em);

However, latest Chrome version seems to not require those prefixes. Maybe you should update your broswer, too.

Upvotes: 1

Related Questions