Problems Configuring Gradient in CSS

Asked

Viewed 436 times

0

I want to put a background on the web page with gradient effect, but that’s the result I’m getting;

inserir a descrição da imagem aqui

This very ugly.

I used this configuration in CSS;

body {
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
    margin: 0px;
    font-weight: normal;
    background-color:#205E99;
    background-image: linear-gradient(to bottom, rgba(255,255,255,.1), rgba(255,255,255,.4), rgba(255,255,255,0), rgba(255,255,255,.4)); 
}

Whereas the effect I want it to have is similar to that;

inserir a descrição da imagem aqui

How do I do?

3 answers

1

With the reference you posted, I believe it has improve the gradient code, I recommend using the following standard:

body {
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
    margin: 0px;
    font-weight: normal;
    background: -webkit-linear-gradient(90deg, #fff 10%, #205E99 90%); /* Chrome 10+, Saf5.1+ */
    background:    -moz-linear-gradient(90deg, #fff 10%, #205E99 90%); /* FF3.6+ */
    background:     -ms-linear-gradient(90deg, #fff 10%, #205E99 90%); /* IE10 */
    background:      -o-linear-gradient(90deg, #fff 10%, #205E99 90%); /* Opera 11.10+ */
    background:         linear-gradient(90deg, #fff 10%, #205E99 90%); /* W3C */
}

NOTE: Usually I pick up on the site http://uigradients.com/ and change the colors.

  • If you want to move the angle, just move the deg

0

Try this and you will see a gradient similar to the one you want:

<div class="gra"></div>

.gra{
  background-image: linear-gradient(to right, #fff, #0000FF);
  height: 100px;
  border: 1px solid #e7e7e7;
  margin: 50px;
}
  • Only a hint to embody the answer, is that the size of the "container" will also influence the result he wants. In his current case Body is not even getting 100% of the Height of the Screen. And that will influence it, but when he adds the rest of the content, that was to resolve.

  • @Michaelalves if the height or width is too small will look ugly the result but when aimed at 1000px both still looks beautiful. https://jsfiddle.net/9m9PV/65/

-1

Using the powerful Gradient Generator

.gradient{
  width:500px;
  height:500px;

  /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#a0a5ff+0,2737fe+100 */
  background: rgb(160,165,255); /* Old browsers */
  background: -moz-linear-gradient(-45deg,  rgba(160,165,255,1) 0%, rgba(39,55,254,1) 100%); /* FF3.6+ */
  background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,rgba(160,165,255,1)), color-stop(100%,rgba(39,55,254,1))); /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(-45deg,  rgba(160,165,255,1) 0%,rgba(39,55,254,1) 100%); /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(-45deg,  rgba(160,165,255,1) 0%,rgba(39,55,254,1) 100%); /* Opera 11.10+ */
  background: -ms-linear-gradient(-45deg,  rgba(160,165,255,1) 0%,rgba(39,55,254,1) 100%); /* IE10+ */
  background: linear-gradient(135deg,  rgba(160,165,255,1) 0%,rgba(39,55,254,1) 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a0a5ff', endColorstr='#2737fe',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
<div class="gradient"></div>  

  • pq the downvote? this does not answer the question?

Browser other questions tagged

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