Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Menú responsive con HTML y CSS

Tiempo de lectura: 2 minutos

Un menú responsive quiere decir que este, es visible tanto en pc, como en tables y móviles, se trata de marcar los puntos de ruptura donde quieres que cambie la vista sin que se descoloque el contenido.

A continuación os dejo un ejemplo:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Menú Responsive</title>
</head>
<body>
<header>
<h1>Menú</h1>
</header>
<nav>
<ul>
<li><a href="#">Inicio</a></li>
<li><a href="#">Sobre nosostros</a></li>
<li><a href="#">Cursos</a></li>
<li><a href="#">Contactos</a></li>
</ul>
<div class="oculto">
<i class="fa fa-bars" aria-hidden="true"></i>
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(".oculto").on('click', function(){
$("nav ul").toggle('show');
})
</script>
</body>
</html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <title>Menú Responsive</title> </head> <body> <header> <h1>Menú</h1> </header> <nav> <ul> <li><a href="#">Inicio</a></li> <li><a href="#">Sobre nosostros</a></li> <li><a href="#">Cursos</a></li> <li><a href="#">Contactos</a></li> </ul> <div class="oculto"> <i class="fa fa-bars" aria-hidden="true"></i> </div> </nav> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> $(".oculto").on('click', function(){ $("nav ul").toggle('show'); }) </script> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <title>Menú Responsive</title>
</head>
<body>
    <header>
        <h1>Menú</h1>
    </header>
    <nav>
        <ul>
            <li><a href="#">Inicio</a></li>
            <li><a href="#">Sobre nosostros</a></li>
            <li><a href="#">Cursos</a></li>
            <li><a href="#">Contactos</a></li>
        </ul>
        <div class="oculto">
            <i class="fa fa-bars" aria-hidden="true"></i>
        </div>
    </nav>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script>
      $(".oculto").on('click', function(){
          $("nav ul").toggle('show');
      }) 
    </script>
</body>
</html>
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
font-family:"Times New Roman", Times, serif;
font-size: 20px;
}
header {
width: 100%;
padding: 100;
background-color:#4A235A;
color: white;
text-align:center;
}
nav ul {
text-align: center;
list-style: none;
background-color: #AF7AC5;
}
nav ul li{
display: inline-block;
padding: 20px;
transition: all ease-in-out 250ms;
}
ul li a {
text-decoration: none;
color: white;
}
nav ul li:hover {
background-color:#4A235A;
}
.oculto {
font-size: 22px;
padding: 16px;
display: none;
background-color:#4A235A;
color: white;
cursor: pointed;
}
@media (max-width:768px) {
ul li {
width: 100%;
padding: 16px;
text-align: left;
}
nav ul {
display: none;
}
.oculto{
display: block;
}
}
*{ margin: 0; padding: 0; box-sizing: border-box; } body{ font-family:"Times New Roman", Times, serif; font-size: 20px; } header { width: 100%; padding: 100; background-color:#4A235A; color: white; text-align:center; } nav ul { text-align: center; list-style: none; background-color: #AF7AC5; } nav ul li{ display: inline-block; padding: 20px; transition: all ease-in-out 250ms; } ul li a { text-decoration: none; color: white; } nav ul li:hover { background-color:#4A235A; } .oculto { font-size: 22px; padding: 16px; display: none; background-color:#4A235A; color: white; cursor: pointed; } @media (max-width:768px) { ul li { width: 100%; padding: 16px; text-align: left; } nav ul { display: none; } .oculto{ display: block; } }
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    font-family:"Times New Roman", Times, serif;
    font-size: 20px;
}

header {
    width: 100%;
    padding: 100; 
    background-color:#4A235A;
    color: white;
    text-align:center; 
}

nav ul { 
    text-align: center;
    list-style: none;
    background-color: #AF7AC5;
   
}
nav ul li{
    display: inline-block;
    padding: 20px;
    transition: all ease-in-out 250ms;
}
ul li a {
    text-decoration: none; 
    color: white;
  
}
nav ul li:hover {
    background-color:#4A235A;
}
.oculto {
    font-size: 22px;
    padding: 16px;
    display: none;
    background-color:#4A235A;
    color: white;
    cursor: pointed;
    
}

@media (max-width:768px) {
    ul li {
        width: 100%;
        padding: 16px;
        text-align: left;
    }
    nav ul {
        display: none;
    }
    .oculto{
        display: block;
    }
}

Esto es todo, espero que os sirva, pero sobre todo que lo disfruteis.

0

Deja un comentario