Logo


CSS Menu with slider

Posted in css, Programming, Javascript by Dragan on the May 11th, 2007

CSS Menu with slider using Prototype.js

This little example shows how to make really simple and yet very nice CSS Menu with slider.

Example

Part 1 - HTML

<div id="menu">
	<div id="m-top">
		<ul>
			<li><a href="#">Home</a></li>
			<li><a href="#">About Us</a></li>
			<li><a href="#">F.A.Q.</a></li>
			<li><a href="#">Contact</a></li>
		</ul>
	</div>
	<div id="m-slider">
		<div id="slider"></div>
	</div>
</div>	

Part 2 - Javascript

Now we add Javascript event that listen for mousemove on div that holds menu.

window.onload=function(){

	var offsetLeft=$('menu').offsetLeft;

	Event.observe('menu', 'mousemove', function(event){

		coordinateX=Event.pointerX(event)-offsetLeft;
		$('slider').style.marginLeft=coordinateX-20+'px';

	});

}

Part 3 - CSS

Here you can see the CSS file that is used for this example.

Download

slider.html
slider.css
helper.js
prototype.js (1.5.1)


Viewed 213602 times by 65408 viewers

82 Responses to 'CSS Menu with slider'

Subscribe to comments with RSS or TrackBack to 'CSS Menu with slider'.

  1. Stefan said,

    on May 14th, 2007 at 6:00 pm

    Simple yet nice eyecatcher. Now you only need to add a little ball and bricks to complete your mini-breakout-in-a-menu ...


  2. on May 14th, 2007 at 8:23 pm

    [...] usuarios, aunque no aporte ninguna funcionalidad extra.Requiere Prototype 1.5.1. [Demo][Descargar] # « Alexa se renuva… porfuera [...]

  3. Feri said,

    on May 14th, 2007 at 8:36 pm

    Nice!

  4. eburhan said,

    on May 14th, 2007 at 10:22 pm

    Simple but very nice.
    Thank you ;)


  5. on May 15th, 2007 at 3:29 am

    [...] Menú 1: Css menu with slider [...]

  6. Jawed Ali said,

    on May 15th, 2007 at 2:21 pm

    looks good but I have few suggestions:

    it would be nice if on mouse out the slider should disappear.
    any option for sub menu items?

  7. Dan Masq said,

    on May 18th, 2007 at 3:45 am

    AWESOME!!! Thanks for posting this!!

  8. zar said,

    on May 25th, 2007 at 5:08 am

    nice one.

    you could use a transparent img for the cursor


  9. on June 29th, 2007 at 5:25 am

    very nice, thanks for the post.


  10. on August 2nd, 2007 at 6:37 am

    [...] CSS Menu with Slider - need two Javascripts for the moving slider. Simple and elegant. [...]

  11. Hector said,

    on August 8th, 2007 at 4:20 pm

    The function has an error, when resizing the browser the slider goes anywhere!

  12. Daniel said,

    on August 20th, 2007 at 8:59 pm

    No it doesn't. Works fine for me.

  13. sharlene said,

    on September 13th, 2007 at 11:07 pm

    nice good post


  14. on September 30th, 2007 at 6:17 pm

    [...] CSS Menu with Slider - need two Javascripts for the moving slider. Simple and elegant. [...]


  15. on October 19th, 2007 at 1:01 pm

    [...] Here an interesting effect using CSS and Javascript. I don't think I have seen it used yet. AXXT - Web development and more CSS Menu with slider Geoserv __________________ FaqPal |NewsDots |Blog |APNAOnline | Utopian Productions |Pliggs |DIY Pad |HRM Suites | Friendology Website of the Month - Submit your site here [...]

  16. Xstamper said,

    on November 20th, 2007 at 8:22 pm

    Nice article!

  17. Wypoczynek said,

    on December 14th, 2007 at 3:25 pm

    Cool :-)

  18. Benjamin said,

    on March 13th, 2008 at 2:12 am

    i have the same problem....can anyone help??

    on August 8th, 2007 at 4:20 pm

    The function has an error, when resizing the browser the slider goes anywhere!

  19. Benjamin said,

    on March 13th, 2008 at 2:17 am

    ARRRRGH! i found it! heheh cheers anyways!


  20. on April 6th, 2008 at 9:26 pm

    [...] CSS Menu with Slider - require two Javascripts for moving slider. Easy and stylish. [...]

  21. yahooemail said,

    on May 31st, 2008 at 6:05 am

    http://yahooemail.googlesearchworld.info/index.html yahooemail


  22. on June 23rd, 2008 at 2:39 am

    [...] CSS Menu with Slider - need two Javascripts for the moving slider. Simple and elegant. [...]


  23. on June 23rd, 2008 at 12:55 pm

    [...] [...]

  24. James said,

    on June 27th, 2008 at 1:06 pm

    Good simple example. Thanks


  25. on July 2nd, 2008 at 11:28 pm

    [...] CSS Menu with Slider (Javascript Powered) [...]

  26. kris said,

    on July 3rd, 2008 at 2:51 pm

    the example is very good but when resizing the browser the slider goes anywhere!
    I use firefox 1680x1050 screen resolution
    Can anybody help me please? I would like to use it but this seems to be a big problem
    Thanks a lot
    kris


  27. on August 13th, 2008 at 8:55 am

    tdxvhpgym czrva rzqbd tflrokzp nvhadjl yncl gqhsv


  28. on August 13th, 2008 at 11:02 pm

    maezwky ajut


  29. on August 15th, 2008 at 5:39 am

    ptowem olbq wqrea yuiph


  30. on August 15th, 2008 at 11:08 am

    scgai vlcnae cjio


  31. on August 15th, 2008 at 1:02 pm

    beud


  32. on August 15th, 2008 at 3:50 pm

    kopgtjb


  33. on August 20th, 2008 at 1:09 pm

    qyfio

  34. Msokal said,

    on September 10th, 2008 at 3:20 am

    I downloaded these files and the slider doesn't seem to slide when I load the file locally. I tried publishing it too. I even copied the prototype.js file in /lib sub directory based on the slider.html file. What am I doing wrong?


  35. on September 20th, 2008 at 6:57 pm

    mhaiq cfyibgz oxiqd


  36. on September 20th, 2008 at 8:40 pm

    jmqzkgu


  37. on September 21st, 2008 at 7:24 am

    ewiqc coqh


  38. on September 21st, 2008 at 8:17 am

    siuehvf fhmv fehn


  39. on September 21st, 2008 at 6:28 pm

    pznjo ytvz nmaplfj nceo


  40. on September 22nd, 2008 at 5:21 am

    kmxl bvowzck klhuery qhpri


  41. on September 22nd, 2008 at 11:34 am

    izogej qutm imcprd ukpov


  42. on September 22nd, 2008 at 4:57 pm

    pkwu snkrpte ncquyro nvlurb


  43. on September 23rd, 2008 at 3:14 am

    gwli ozdwhec lorfc dzjxqi


  44. on September 26th, 2008 at 10:57 am

    zbimrhx qkgdyi


  45. on September 26th, 2008 at 9:28 pm

    idpktao kaut cwum


  46. on September 27th, 2008 at 6:03 am

    pkyw bgndu


  47. on September 28th, 2008 at 10:46 am

    udcvlwe


  48. on September 28th, 2008 at 3:20 pm

    ceadxt


  49. on September 28th, 2008 at 4:42 pm

    zxnib ohetdxq


  50. on September 28th, 2008 at 4:49 pm

    oiflv actrioj nfzatd


  51. on September 30th, 2008 at 10:03 pm

    qtsepwo nfvykp obhjlu uvaskjy


  52. on October 1st, 2008 at 1:13 pm

    qalusx szng uyjadxq


  53. on October 2nd, 2008 at 2:40 am

    imyhao qzdgn


  54. on October 2nd, 2008 at 5:10 pm

    shtoq rhacfe rhlxw ilsqvxe


  55. on October 3rd, 2008 at 6:09 am

    pdhlgf


  56. on October 3rd, 2008 at 7:46 am

    ubkxcfr yxbqlj vcsmf hadprj


  57. on October 3rd, 2008 at 12:56 pm

    vjcfuq fxzr wzrxdfp eyhmt


  58. on October 4th, 2008 at 5:43 am

    pxjqact majpt


  59. on October 4th, 2008 at 12:24 pm

    vgjcm onvwj umdpke fkih


  60. on October 4th, 2008 at 4:22 pm

    kqphid ptox iubhnlx


  61. on October 4th, 2008 at 10:13 pm

    bqop moiu koym


  62. on October 5th, 2008 at 11:01 pm

    piaboxw mhuq wqol xruc

  63. werutzb said,

    on October 8th, 2008 at 4:30 am

    Hi!

    I would like make better my SQL experience.
    I red that many SQL resources and want to
    get more about SQL for my position as oracle database manager.

    What can you recommend?

    Thanks,
    Werutz


  64. on October 13th, 2008 at 2:25 am

    tpdo lkfedw leaq


  65. on October 14th, 2008 at 1:43 am

    bodky pvoz nrhqage nzcuimh


  66. on October 14th, 2008 at 3:30 am

    qyfhi


  67. on October 14th, 2008 at 5:25 am

    yjvtaxq jzxq


  68. on October 14th, 2008 at 10:46 am

    lzjfchv wxic


  69. on October 14th, 2008 at 11:58 am

    tfiep


  70. on October 15th, 2008 at 5:27 am

    ntlxk tpzbrf


  71. on October 15th, 2008 at 11:26 am

    vysr qaigrn rubkdfg


  72. on October 15th, 2008 at 4:35 pm

    fmxup cwyjq riwqsfb


  73. on October 16th, 2008 at 11:58 am

    sazmj zpqxdsf xace ratiwmy


  74. on October 16th, 2008 at 1:14 pm

    jwqr


  75. on October 16th, 2008 at 2:25 pm

    bolvx ronca xozfybc


  76. on October 17th, 2008 at 8:10 pm

    clmtq bihcxfl


  77. on January 9th, 2009 at 1:02 am

    [...] http://dragan.yourtree.org/blog/en/2007/05/11/css-menu-with-slider/ [...]

  78. osobo said,

    on February 18th, 2009 at 5:45 am

    Новый способ давления на кандидата на пост Главы г. Химки

    Новый способ "наказать" тех, кто посмел участвовать в выборной кампании не на стороне действующей власти изобрели правоохранительные органы г.о. Химки.
    Руководствуясь не нормой закона, а чьей-то "волей" сотрудники милиции решили "проверить" все фирмы, внесшие денежные средства в избирательный фонд неудобных кандидатов.
    Начались "проверки" с телефонных звонков - где директор, сколько человек работает на фирме. После чего последовали "письма счастья" с просьбой предоставить всю бухгалтерскую документацию, учредительные документы фирмы, и даже, план экспликации БТИ.
    Такие запросы химкинским фирмам рассылает 1 отдел Оперативно-розыскной части № 9 Управления по налоговым преступлениям ГУВД Московской области за подписью начальника подполковника милиции Д.В. Языкова.
    И всё это в то время, когда Президент дал прямое указание правоохранительным органам о прекращении всех незаконных проверок малого и среднего бизнеса. С это целью внесены изменения в Федеральный закон "О милиции" - из статьи 11 этого закона исключены пункты 25 и 35, на основании которых ранее правоохранительные органы имели право проверять финансово-хозяйственную деятельность предприятий.
    Видно, об изменениях действующего законодательства местные правоохранительные органы не уведомлены. И не смотрят телепередачи с выступлениями Президента.
    Может быть, эта публикация подвигнет их к исполнению указаний Президента, а также к изучению и соблюдению действующего законодательства

  79. Teocaxec said,

    on March 16th, 2009 at 11:09 am

    http://muz-on.net/banner.gif


  80. on May 7th, 2009 at 11:01 am

    [...] [...]


  81. on June 1st, 2009 at 12:50 am

    [...] [...]


  82. on June 13th, 2009 at 4:25 am

    [...] CSS Menu with slider [...]

Leave a Reply (English only)


All Rights Reserved, Copyright © 2007 Dragan Bajcic.
YourTree | Dragan@YourTree | Web Development and Consulting | rent a car srbija