Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
Link Element Not Displaying When Selected And Styled As nth-of-type

https://codesandbox.io/s/damp-worker-k7fj6y?file=/src/App.js

Why is the .row:nth-of-type(1) > .content:nth-of-type(4) .content <Link/> not displaying?

Is it a bug, am I just missing something?

import "./styles.css";
import { Link } from "react-router-dom";

export default function App() {
  return (
    <div className="App">
      <div className="row">
        {/* I dont want this div to be a Link */}
        <div className="content"></div>
        <Link to="/" className="content"></Link>
        <Link to="/" className="content"></Link>
        <Link to="/" className="content"></Link>
      </div>
      <div className="row">
        <Link to="/" className="content"></Link>
        <Link to="/" className="content"></Link>
        <Link to="/" className="content"></Link>
        <Link to="/" className="content"></Link>
      </div>
    </div>
  );
}
.App {
  height: 100vh;
  width: 100vw;
}

.row:nth-of-type(1) {
  height: 500px;
  width: 100%;
  display: grid;
  grid-template-areas:
    "a a b c"
    "a a d d";
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 20px;
}

.row:nth-of-type(1) > .content:nth-of-type(1) {
  grid-area: a;
  background-color: orange;
}
.row:nth-of-type(1) > .content:nth-of-type(2) {
  grid-area: b;
  background-color: blue;
}
.row:nth-of-type(1) > .content:nth-of-type(3) {
  grid-area: c;
  background-color: green;
}
.row:nth-of-type(1) > .content:nth-of-type(4) {
  grid-area: d;
  background-color: red;
}

wheres the red content

I am not looking for an alternative approach to achieve the same result, I am simply asking why the fourth <Link/> is not displaying so I know what is going wrong.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Use the :nth-child psuedoselector since you are mixing element types (div and Link (a)), there isn't a 4th link type element to style.

.row:nth-of-type(1) > .content:nth-child(1) {
  grid-area: a;
  background-color: orange;
}
.row:nth-of-type(1) > .content:nth-child(2) {
  grid-area: b;
  background-color: blue;
}
.row:nth-of-type(1) > .content:nth-child(3) {
  grid-area: c;
  background-color: green;
}
.row:nth-of-type(1) > .content:nth-child(4) {
  grid-area: d;
  background-color: red;
}

enter image description here

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda