Código de JavaScript - Menú Horizontal ocultable OnScroll

Requerimientos

Un navegador web y/o dispositivo compatible.

1.0
estrellaestrellaestrellaestrellaestrella(2)

Publicado el 22 de Septiembre del 2018gráfica de visualizaciones de la versión: 1.0
2.176 visualizaciones desde el 22 de Septiembre del 2018
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

Versión 1.0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<style>
body {
  margin: 0;
  background-color: #f1f1f1;
  font: normal 100%/1.0 sans-serif;
}
 
#navbar {
  top: 0;
  width: 100%;
  display: block;
  position: fixed;
  background-color: #444444;
  -webkit-transition: all 0.4s;
  transition: all 0.4s;
}
 
#navbar a {
  padding: 16px;
  color: #f2f2f2;
  font-size: 16px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
 
#navbar a:hover {
  color: #000000;
  background-color: #dddddd;
}
</style>
</head>
<body>
 
<div id="navbar">
  <a href="#home">Home</a>
  <a href="#news">News</a>
  <a href="#fotos">Fotos</a>
  <a href="#contact">Contact</a>
</div>
 
<div style="padding:16px 16px 1400px;font-size:24px;margin-top:24px;">
  <p><b>This example demonstrates how to hide a navbar when the user starts to scroll the page.</b></p>
  <p>Scroll down to see the effect.</p>
  <p>Scroll up to show the navbar.</p>
  <p>Lorem ipsum dolor dummy text sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  <p>Lorem ipsum dolor dummy text sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
 
<script>
window.onscroll = function() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("navbar").style.top = "-48px";
} else {
document.getElementById("navbar").style.top = "-00px";
}
}
</script>
</body>
</html>



Comentarios sobre la versión: 1.0 (2)

Imágen de perfil
22 de Septiembre del 2018
estrellaestrellaestrellaestrellaestrella
Uala!!! que chulo ScriptShow!!!!

Muy bien conseguido!!!
Responder
9 de Noviembre del 2018
estrellaestrellaestrellaestrellaestrella
gracias por compartir
Responder

Comentar la versión: 1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s4834