Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
Error con un pequeño CSS de barra de navegación del sitio web que estoy haciendo

Tengo un problema con el CSS de la barra de navegación de un sitio web. Por favor, ayúdame a mover los elementos al lado derecho y a lidiar con la capacidad de respuesta.

HTML:

 <nav> <a href="#" class="logo"><img src="./images/logo.png" height="120" width="120"></a> <ul> <li><a class="active" href="#">Home</a></li> <li><a href="#">How to MUN</a></li> <li><a href="#">Sponsors</a></li> <li><a href="#">Contact</a></li> </ul> </nav>

CSS:

 body, html { height: 100%; margin: 0; font-size: 16px; font-family: "Lato", sans-serif; font-weight: 400; line-height: 1.8em; color: #666; } nav { position: absolute; display: flex; align-items: center; padding: 30px 90px; z-index: 99; } nav .logo { color: #fff; font-weight: 700; text-decoration: none; font-size: 2rem; text-transform: uppercase; letter-spacing: 2px; } nav ul { display: flex; justify-content: center; align-items: center; } nav ul li { list-style: none; margin-left: 20px; } nav ul li a { text-decoration: none; padding: 6px 15px; color: #ffff; border-radius: 20px; } nav ul li a:hover, .active { background: #fff; color: #2b1055; }

Lo he intentado muchas veces pero no soy capaz de solucionar el problema. Los elementos siempre se mantienen unidos.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

body, html { height: 100%; margin: 0; font-size: 16px; font-family: "Lato", sans-serif; font-weight: 400; line-height: 1.8em; color: #666; } nav { position: relative; background: rgb(31, 30, 30); display: flex; align-items: center; justify-content: space-between; padding: 30px 90px; z-index: 99; } nav .logo { color: #fff; font-weight: 700; text-decoration: none; font-size: 2rem; text-transform: uppercase; letter-spacing: 2px; } nav ul { display: flex; justify-content: center; align-items: center; } nav ul li { list-style: none; margin-left: 20px; } nav ul li a { text-decoration: none; padding: 6px 15px; color: #fff; border-radius: 20px; white-space: nowrap; } nav ul li a:hover, .active { background: #fff; color: #2b1055; } /* breakpoint for mobile */ @media screen and (max-width: 768px) { nav { flex-direction: column; padding: 20px 0px; } }

si desea un menú de respuesta más avanzado, puede ocultar el menú de navegación y agregar el botón de hamburguesa y luego usar css: enfoque para expandir el menú de navegación cuando haga clic en el botón de hamburguesa o use algún código javascript/jquery

about 4 years ago · Juan Pablo Isaza Report

0

Prueba esto

He agregado una consulta de medios para una vista receptiva. Cuando la resolución es inferior a 768 px, la barra de navegación cambia a la vista de columna

 body, html { height: 100%; margin: 0; font-size: 16px; font-family: "Lato", sans-serif; font-weight: 400; line-height: 1.8em; color: #666; } nav { display: flex; align-items: center; padding: 12px 90px; z-index: 99; background-color:#7c7c7c; } nav .logo { color: #fff; font-weight: 700; text-decoration: none; font-size: 2rem; text-transform: uppercase; letter-spacing: 2px; } nav ul { display: flex; justify-content: right; align-items: center; width:100%; } nav ul li { list-style: none; margin-left: 20px; } nav ul li a { text-decoration: none; padding: 6px 15px; color: #ffff; border-radius: 20px; } nav ul li a:hover, .active { background: #fff; color: #2b1055; } @media only screen and (max-width: 767px){ nav { flex-direction: column; } nav ul { flex-direction: column; padding:0px; margin-bottom:0px; } nav ul li{ margin-left:0px; margin-bottom:5px; } }
 <nav> <a href="#" class="logo"><img src="https://images.unsplash.com/photo-1557053964-937650b63311?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=997&q=80" width="80"></a> <ul> <li><a class="active" href="#">Home</a></li> <li><a href="#">How to MUN</a></li> <li><a href="#">Sponsors</a></li> <li><a href="#">Contact</a></li> </ul> </nav>

about 4 years ago · Juan Pablo Isaza Report

0

En primer lugar, debe hacer que la posición sea relativa.

en segundo lugar;

  • establecer ancho de 100%
  • flote hacia la derecha y agregue el margen derecho a la cantidad de píxeles que desee.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!