Remove type when value is 0

Asked

Viewed 38 times

1

I have the Web Essentials installed in my Visual Studio, and he made me the following recommendation:

inserir a descrição da imagem aqui

Logo, I removed the drive type. The style worked perfectly on Chrome, but while testing on Firefox and IE, it was found invalid.

Sample code:

.mydiv {
  width: 100%;
  height: 100px;
  background: linear-gradient(0, red, yellow);
  border: solid black 1px;
}
<div class="mydiv"></div>

It would be even good practice to remove the drive type from the CSS when the value is 0?

Is there any alternative but to insert the unit type?

  • "it was considered invalid" By that you mean you rolled some error in the console or that the gradient did not work?

  • that the gradient didn’t work... No message on the console, but the Firefox warns the reason

  • No edge worked for me, testing the snippet.

  • 2

    @Edilson I read IE in the publication and interpreted as Edge, my fault.

1 answer

0

Hello, then to work in other browsers follows below an example:

background: -webkit-linear-gradient(left, #77e859 , #8ec982); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right, #77e859, #8ec982); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, #77e859, #8ec982); /* For Firefox 3.6 to 15 */

And the unit, I think it’s okay to put the 0.

It will take that helps you to work in other browsers...

.mydiv {
  width: 100%;
  height: 100px;
  background: linear-gradient(0, red, yellow);
  background: -webkit-linear-gradient(0, red, yellow); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(0, red, yellow); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(0, red, yellow); /* For Firefox 3.6 to 15 */
  border: solid black 1px;
}
<div class="mydiv"></div>

References

  • @nathn thank you so much for the answer, the gradient appeared, but it is with the angle reversed. The strange thing is that looking at in this example in the Mozilla documentation, they did the last line with an inverted parameter, and now I got a little more confused.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.