Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
How could I apply a linear-gradient to an element in css?

I have the following code:

#trapezoid {
  border-bottom: 150px solid red;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  height: 0;
  width: 30px;
}
<div id='trapezoid'></div>
My question is how could I apply linear-gradient to it (the whole shape).

Background:linear-gradient will not going to work since I use border to construct the shape.

Any trick I could use?

Thanks

P.S this is not a duplicate of this answer:

How to create multi-color border with CSS?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can create a trapezoid using CSS clip-path. That way you can set the background-image to a linear-gradient.

.trapezoid {
  width: 20vmin;
  height: 40vmin;
  clip-path: polygon(0 100%, 20% 0, 80% 0, 100% 100%);
  background-image: linear-gradient(red, blue);
}
<div class="trapezoid"></div>

about 4 years ago · Juan Pablo Isaza Relatório

0

Here's an SVG trapezoid that has a background linear gradient and also rotates.

@keyframes rotating {
    from{
        transform: rotate(0deg);
    }
    to{
        transform: rotate(360deg);
    }
}

.shape {
    animation: rotating 2s linear infinite;
}
<svg viewBox="0 0 30 20" class="shape" style="width:300px">
  <defs>
    <linearGradient id="grad" x2="0" y2="1">
      <stop offset="0%" stop-color="red"/>
      <stop offset="100%" stop-color="black"/>
    </linearGradient>
  </defs>
  
  <polygon points="0, 0, 30, 0, 22, 20, 8, 20" fill="url(#grad)"/>
</svg>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda