Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/wp-db.php on line 760
Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/wp-db.php on line 760
Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/wp-db.php on line 760
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/comment-template.php on line 1745
Deprecated: wp_getimagesize(): Implicitly marking parameter $image_info as nullable is deprecated, the explicit nullable type must be used instead in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/media.php on line 5180
Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/pomo/streams.php on line 26
Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/pomo/streams.php on line 29
Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/pomo/streams.php on line 160
Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/pomo/translations.php on line 293
Deprecated: Creation of dynamic property WP_Block_Type::$skip_inner_blocks is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-block-type.php on line 357
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/class-wp-term.php on line 198
Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/wp-db.php:760) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/feed-rss2.php on line 8
En el denominado «efecto nudging» –codazo– que yo traduciría mejor como «empujoncito», el hecho de que las letras se desplacen un poco y que en ocasiones aparezca una flecha es como decir: venga… anímate y pasa. Así que voy a estudiar un poco cómo está construída esta «invitación» utilizando JQuery y CSS.
Lo esencial en esta lista, es que a cada elemento debemos asignarle la clase relacionada con el efecto, que es: nudge (cuyo nombre respetaré en inglés porque es una palabra muy específica que significa –dar suavemente con el codo-, y no está de más agregarla a nuestro vocabulario técnico.

![]()
Lo quedebemos destacar del estilo es que para la etiqueta de enlace anchor (a) se modifica la imagen de fondo al poner el ratón encima y por acción del script cambia también el padding original de 15px a 35px. Por supuesto, todas estas medias varían dependiendo del tamaño y forma del menú.
Primero localizamos el elemento al que se la ha aplicado la regla de estilo «nudge». La clase .hover permite manejar los dos estados del elemento sobre el que se pasa el raton: uno cuando «entra» y otro cuando «sale». En ambos estados se aplica .animate, a la que se le pasa como primer parámetro la regla» padding» y como segundo el tiempo en milisegundos que esta animación debe durar.
<div id="menu"> <ul> <li><a href="#" class="nudge">home</a></li> <li><a href="#" class="nudge">acerca de nosotros </a></li> <li><a href="#" class="nudge">servicios</a></li> <li><a href="#" class="nudge">productos</a></li> <li><a href="#" class="nudge">contacta con nosotros</a></li> </ul> </div>
Lo esencial en esta lista, es que a cada elemento debemos asignarle la clase relacionada con el efecto, que es: nudge (cuyo nombre respetaré en inglés porque es una palabra muy específica que significa –dar suavemente con el codo-, y no está de más agregarla a nuestro vocabulario técnico.
<script language="javascript">
$(document).ready(function() {
$('a.nudge').hover(function() {
$(this).animate({ paddingLeft: '35px' }, 400);
}, function() {
$(this).animate({ paddingLeft: '15px' }, 400);
});
});
</script>
Localizamos el elemento al que se la ha aplicado la regla de estilo «nudge». La clase .hover permite manejar los dos estados del elemento sobre el que se pasa el raton: uno cuando «entra» y otro cuando «sale». En ambos estados se aplica .animate, a la que se le pasa como primer parámetro la regla» padding» y como segundo el tiempo en milisegundos que esta animación debe durar.
#menu_nudging{
width:235px;
background-color: #fff;
}
#menu_nudging ul{
list-style:none;
}
#menu_nudging li{
list-style:none;
margin:1px 0;
}
#menu_nudging li a{
list-style:none;
background: url(../imagenes/efecto_nudging/fdo_normal.gif) no-repeat;
color:#fff;
text-transform:uppercase;
font-size:14px;
text-decoration:none;
display:block;
height:30px;
line-height:30px;
padding:0 0 0 15px;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
#menu_nudging li a:hover{
background: url(../imagenes/efecto_nudging/fdo_sobre.gif) no-repeat;
color:#fff;
text-decoration:none;
}
La referencia para esta práctica la he tomado del blog de webintenta, al que te remito para completar la información y distrutar de alguno de sus excelentes artículos. Espero que te la hayas pasado bien por aquí.
]]>Cuando sitúe el puntero del ratón sobre este enlace, aparecerá un pequeño texto de información. Al mover el puntero, la caja de texto se moverá también mientras nos encontremos dentro de los límites del enlace, y desaparecerá cuando nos alejemos. Para conseguir este resultado necesitamos:
Pasa el puntero por el siguiente enlace de Plantillas para obtener una vista previa de la imagen. Y en el enlace de PCPolis encontrarás la misma imagen que incluye un texto explicativo.
A continuación relaciono los problemas con los que me encontré llevando a la práctica los ejemplos de este artículo y la forma en que pude solucionarlos. Me parece una buena idea incluir este apartado, pues la mayoría de las veces cometemos errores que suelen ser comunes y a pesar de ser pequeños generan auténticos dolores de cabeza.
Alen Grakalic (http://cssglobe.com)
En cssglobe puedes ver el artículo original en inglés y descargar los archivos de ejemplo. Espero que hayas disfrutado y que este artículo haya resultado de utilidad.
/* ESTILOS PARA TOOLTIP
Ejemplo 1 */
#emergente1 h1{
font-size:180%;
font-weight:normal;
color:#555;
}
#emergente1 a{
text-decoration:none;
color:#f30;
}
#emergente1 a:hover {
background-color: transparent;
}
#emergente1 p{
clear:both;
margin:0;
padding:.5em 0;
}
#emergente1 pre{
display:block;
font:100% «Courier New», Courier, monospace;
padding:10px;
border:1px solid #bae2f0;
background:#e3f4f9;
margin:.5em 0;
overflow:auto;
width:800px;
}
#tooltip{
position:absolute;
border:1px solid #CCCCCC;
padding:2px 5px;
color:#FFFFFF;
display:none;
background-color: #2d83d5;
font-weight: bold;
}
#emergente a:hover {
background-color: transparent;
}
/* Ejemplo 2 */
#emergente2 {
display:block;
overflow:hidden;
}
#emergente2 h1{
font-size:180%;
font-weight:normal;
color:#555;
}
#emergente2 h2{
clear:both;
font-size:160%;
font-weight:normal;
color:#555;
margin:0;
padding:.5em 0;
}
#emergente2 a{
text-decoration:none;
color:#f30;
}
#emergente2 p{
clear:both;
margin:0;
padding:.5em 0;
}
#emergente2 pre{
display:block;
font:100% «Courier New», Courier, monospace;
padding:10px;
border:1px solid #bae2f0;
background:#e3f4f9;
margin:.5em 0;
overflow:auto;
width:800px;
}
#emergente2 img {
border: 1px solid #CCCCCC;
margin-bottom:7px;
}
#emergente2 ul,li{
margin:0!important;
padding:0;
}
#emergente2 li{
list-style:none;
float:left;
display:inline;
margin-right:0px;
}
#preview{
position:absolute;
border:1px solid #ccc;
padding:5px;
display:none;
color:#666666;
background-color: #fff;
text-align: center;
line-height: 2em;
}
#emergente2 a:hover {
background-color: transparent;
}
/* Ejemplo 3 */
#emergente3 h1{
font-size:180%;
font-weight:normal;
color:#555;
}
#emergente3 h2{
clear:both;
font-size:160%;
font-weight:normal;
color:#555;
margin:0;
padding:.5em 0;
}
#emergente3 a{
text-decoration:none;
color:#f30;
}
#emergente3 p{
clear:both;
margin:0;
padding:.5em 0;
}
#emergente3 pre{
display:block;
font:100% «Courier New», Courier, monospace;
padding:10px;
border:1px solid #bae2f0;
background:#e3f4f9;
margin:.5em 0;
overflow:auto;
width:800px;
}
#emergente3 img{border:none;}
#emergente3 ul,li{
margin:0;
padding:0;
}
#emergente3 li {
list-style:none;
float:left;
display:inline;
margin-right:10px;
}
#screenshot {
position:absolute;
border:1px solid #ccc;
background:#333;
padding:5px;
display:none;
color:#fff;
line-height:2em;
text-align:center;
}
#emergente3 a:hover {
background-color: transparent;
}
tooltips.js
/*
* Tooltip script
* powered by jQuery (http://www.jquery.com)
*
* written by Alen Grakalic (http://cssglobe.com)
*
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/
this.tooltip = function(){
/* CONFIG */
xOffset = -18;
yOffset = 0;
// these 2 variable determine popup’s distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$(«a.tooltip»).hover(function(e){
this.t = this.title;
this.title = «»;
$(«body»).append(«<p id=’tooltip’>»+ this.t +»</p>»);
$(«#tooltip»)
.css(«top»,(e.pageY – xOffset) + «px»)
.css(«left»,(e.pageX + yOffset) + «px»)
.fadeIn(«fast»);
},
function(){
this.title = this.t;
$(«#tooltip»).remove();
});
$(«a.tooltip»).mousemove(function(e){
$(«#tooltip»)
.css(«top»,(e.pageY – xOffset) + «px»)
.css(«left»,(e.pageX + yOffset) + «px»);
});
};
// starting the script on page load
$(document).ready(function(){
tooltip();
});
/*
* Image preview script
*/
this.imagePreview = function(){
/* CONFIG */
xOffset = -18;
yOffset = 0;
// these 2 variable determine popup’s distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG NOTAS:
hover es un gestor de evento para cuando se pasa el ratón sobre un objeto
hover( over, out )
*/
$(«a.preview»).hover(function(e){
this.t = this.title;
this.title = «»;
var c = (this.t != «») ? «<br/>» + this.t : «»;
$(«body»).append(«<p id=’preview’><img src='»+ this.href +»‘ alt=’Image preview’ />»+ c +»</p>»);
$(«#preview»)
.css(«top»,(e.pageY – xOffset) + «px»)
.css(«left»,(e.pageX + yOffset) + «px»)
.fadeIn(«fast»);
},
function(){
this.title = this.t;
$(«#preview»).remove();
});
$(«a.preview»).mousemove(function(e){
$(«#preview»)
.css(«top»,(e.pageY – xOffset) + «px»)
.css(«left»,(e.pageX + yOffset) + «px»);
});
};
// starting the script on page load
$(document).ready(function(){
imagePreview();
});
/*
* Url preview script
*/
this.screenshotPreview = function(){
/* CONFIG */
xOffset = -18;
yOffset = 0;
// these 2 variable determine popup’s distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$(«a.screenshot»).hover(function(e){
this.t = this.title;
this.title = «»;
var c = (this.t != «») ? «<br/>» + this.t : «»;
$(«body»).append(«<p id=’screenshot’><img src='»+ this.rel +»‘ alt=’url preview’ />»+ c +»</p>»);
$(«#screenshot»)
.css(«top»,(e.pageY – xOffset) + «px»)
.css(«left»,(e.pageX + yOffset) + «px»)
.fadeIn(«fast»);
},
function(){
this.title = this.t;
$(«#screenshot»).remove();
});
$(«a.screenshot»).mousemove(function(e){
$(«#screenshot»)
.css(«top»,(e.pageY – xOffset) + «px»)
.css(«left»,(e.pageX + yOffset) + «px»);
});
};
// starting the script on page load
$(document).ready(function(){
screenshotPreview();
});