Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Cookie/Jar.php on line 63 Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Cookie/Jar.php on line 73 Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Cookie/Jar.php on line 89 Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Cookie/Jar.php on line 102 Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Cookie/Jar.php on line 111 Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40 Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51 Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68 Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82 Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 Warning: Cannot modify header information - headers already sent by (output started at /mnt/web522/e0/75/511171875/htdocs/blog/wp-content/themes/bootstrap_blog/functions.php:89) in /mnt/web522/e0/75/511171875/htdocs/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1719 {"id":264,"date":"2010-07-17T19:02:29","date_gmt":"2010-07-17T17:02:29","guid":{"rendered":"https:\/\/www.pcpolis.es\/blog\/?p=264"},"modified":"2015-02-12T11:20:15","modified_gmt":"2015-02-12T09:20:15","slug":"menu-con-jquery-y-css","status":"publish","type":"post","link":"https:\/\/www.pcpolis.es\/blog\/css\/menu-con-jquery-y-css\/","title":{"rendered":"Men\u00fa con JQuery y CSS"},"content":{"rendered":"

\u00bfEchas de menos Flash? Los efectos que se logran con este programa son irremplazables, pero ha habido que ceder un poco a favor de la funcionalidad e interactividad de la Web. En cualquier caso Flash tambi\u00e9n es c\u00f3digo, as\u00ed que para conseguir algunos movimientos \u00fatiles tambi\u00e9n nos podemos ayudar de JavaScript, en este caso de la librer\u00eda JQuery.<\/p>\n

Ejemplo 1: Men\u00fa con Desplazamiento Horizontal<\/h6>\n
\n
\"menu1\"<\/a><\/div>\n
\"menu2\"<\/a><\/div>\n
\"menu3\"<\/a><\/div>\n<\/div>\n

HTML<\/h2>\n

Un div contenedor (#menu_hor) y otros tantos div(#menu1, #menu2 y #menu3) como elementos de men\u00fa se quiera.<\/p>\n

CSS<\/h2>\n

Es importante que el div contenedor (#menu_hor) tenga asignada una posici\u00f3n relativa, de esa manera al asignarle una posici\u00f3n absoluta a los tres menus interiores, su posici\u00f3n ser\u00e1 con respecto a este div. Otra propiedad importante sera que el desbordamiento sea oculto, para que \u00fanicamente muestre aquella parte de las imagenes que nos interesa. Sus medidas dependeran de las imagenes que se utilicen.<\/p>\n

Para los elementos del men\u00fa, la clase que apliquemos servir\u00e1 de referenencia para ejecutar los cambios con javascript. Aqu\u00ed lo importante es su posicionamiento, que debe ser absoluto, y su ubicaci\u00f3n dentro del contenedor, que depender\u00e1 de cada elemento: left:0px, left:40px y left:80px. De esa forma se muestran las leyendas situadas en el extremo izquierdo.<\/p>\n

JQuery<\/h2>\n

La clase JavaScript necesaria para conseguir este efecto es .animate()<\/a>, su sintaxis es la siguiente:<\/p>\n

.animate( properties, [ duration ], [ easing ], [ callback ] )<\/strong><\/span><\/p>\n

y la funci\u00f3n clave ser\u00eda la siguiente:<\/p>\n

$(document).ready(function(){\r\n\r\n\t\/* menu1 *\/\r\n\t$(\"#menu1\").mouseover(function(){\r\n      $(\".bloque2\").animate({\"left\": \"440px\"}, \"slow\");\r\n\t  $(\".bloque3\").animate({\"left\": \"480px\"}, \"slow\");\r\n    });\r\n});<\/pre>\n
    \n
  1. En primer lugar nos auxiliamos de un gestor de eventos ( mouseover) que se ha asignado al div #menu1, que desencadena el resto de acciones<\/li>\n
  2. La funci\u00f3n clave, a la que se le pasan dos par\u00e1metros: la propiedad css de la capa que tiene asignada la clase bloque2 y el tiempo en el que se desea que se ejecute esta acci\u00f3n.<\/li>\n<\/ol>\n

    El resto del script, que puedes ver a continuaci\u00f3n en la secci\u00f3n de c\u00f3digo, es una variaci\u00f3n de esta primera parte, combin\u00e1ndola como se desee que ocurran las transiciones en el resto de elementos del men\u00fa.<\/p>\n

    Ver C\u00f3digo(+\/-)<\/a><\/h6>\n
    \n
    \r\n\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\r\n<script src=\"https:\/\/www.pcpolis.es\/blog\/scripts\/jquery-1.4.2.min.js\" type=\"text\/javascript\"><\/script>\r\n\r\n<script>\r\n$(document).ready(function(){\r\n\r\n\/* menu1 *\/\r\n$(\"#menu1\").mouseover(function(){\r\n$(\".bloque2\").animate({\"left\": \"440px\"}, \"slow\");\r\n$(\".bloque3\").animate({\"left\": \"480px\"}, \"slow\");\r\n});\r\n\r\n\/* menu2 *\/\r\n$(\"#menu2\").mouseover(function(){\r\n$(\".bloque2\").animate({\"left\": \"40px\"}, \"slow\");\r\n$(\".bloque3\").animate({\"left\": \"480px\"}, \"slow\");\r\n});\r\n\r\n\/* menu3 *\/\r\n$(\"#menu3\").mouseover(function(){\r\n$(\".bloque3\").animate({\"left\": \"80px\"}, \"slow\");\r\n$(\".bloque2\").animate({\"left\": \"40px\"}, \"slow\");\r\n});\r\n\r\n});\r\n<\/script>\r\n<style>\r\nimg {\r\nborder:none;\r\n}\r\n\r\n#contenedor {\r\nwidth:520px;\r\nbackground-color: #999999;\r\nheight:250px;\r\noverflow:hidden;\r\nposition:relative;\r\n}\r\n\r\n.bloque1 {\r\nbackground-color:#757C08;\r\nleft:0px;\r\nwidth:440px;\r\nheight:250px;\r\nmargin:0px;\r\ntop: 0px;\r\nposition:absolute;\r\n}\r\n\r\n.bloque2 {\r\nbackground-color:#6F8C94;\r\nleft:440px;\r\nwidth:440px;\r\nheight:250px;\r\nmargin:0px;\r\ntop: 0px;\r\nposition:absolute;\r\n}\r\n\r\n.bloque3 {\r\nbackground-color:#782748;\r\nleft:480px;\r\nwidth:440px;\r\nheight:250px;\r\nmargin:0px;\r\ntop: 0px;\r\nposition:absolute;\r\n}\r\n<\/style>\r\n<\/head>\r\n<body>\r\n<div id=\"contenedor\">\r\n
    \"menu1\"<\/a><\/div>\r\n
    \"menu2\"<\/a><\/div>\r\n
    \"menu3\"<\/a><\/div>\r\n<\/div>\r\n<\/body>\r\n<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

    \u00bfEchas de menos Flash? Los efectos que se logran con este programa son irremplazables, pero ha habido que ceder un poco a favor de la funcionalidad e interactividad de la Web. En cualquier caso Flash tambi\u00e9n es c\u00f3digo, as\u00ed que para conseguir algunos movimientos \u00fatiles tambi\u00e9n nos podemos ayudar de JavaScript, en este caso de […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,19],"tags":[29,30],"_links":{"self":[{"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/posts\/264"}],"collection":[{"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/comments?post=264"}],"version-history":[{"count":10,"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":600,"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/posts\/264\/revisions\/600"}],"wp:attachment":[{"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/media?parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/categories?post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pcpolis.es\/blog\/wp-json\/wp\/v2\/tags?post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}