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

178
Visualizações
sibling selector with :before doesn't work in styled-component?

How to use this

li+li:before {
  padding: 8px;
  color: black;
  content: "/\00a0";
}

in styled-component? I tried to convert this https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_breadcrumbs

to styled-component but it's not working.

https://codesandbox.io/s/recursing-pasteur-mkmyh?file=/src/App.js

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

0

The content of the content seems to be the culprit. The rest of the code is fine.

Instead of /\00a0 it should be /\\00a0. It seems to be a styled-components specific issue.

Here's a short quote as an explanation, the source has more in depth discussion.

Basically because you write CSS in JS you have to escape twice - once for JS parser and once for CSS one.

Source/GitHub

Full working code:

import styled from "styled-components";

export default function Namaste() {
  return (
    <UL>
      <li>
        <a href="/#">Home</a>
      </li>
      <li>
        <a href="/#">Pictures</a>
      </li>
      <li>
        <a href="/#">Summer 15</a>
      </li>
      <li>Italy</li>
    </UL>
  );
}

const UL = styled.ul`
  padding: 10px 16px;
  list-style: none;
  background-color: #eee;

  li {
    display: inline;
    font-size: 18px;
    color: red;
  }
  li + li:before {
    padding: 8px;
    color: black;
    content: "/\\00a0";
  }
  li a {
    color: #0275d8;
    text-decoration: none;
  }
`;

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