jQuery カルーセル
カルーセルって何?というところから
カルーセルパネル
Webデザインの一種で画像などを横にスライドさせて見せる表現方法の事。今回試したのは左右に前後の画像が見えているタイプで紹介サイトでもあまり見ないタイプ。下部に画像を選択出来るボタンもある。下記参考サイトのヘッダー部分のようなもの。
参考サイト:LEXUS
使えるプラグインの検索
width: 1000pxにしようと試みるもうまくいかないのでwrapperで囲ってしまいました。久しぶりにweb関係の事をして達成感すごかった。
中身
- htmi+css
<!DOCTYPE html> <html> <head> <!-- This carousel example is created with jQuery and the carouFredSel-plugin. http://jquery.com http://caroufredsel.frebsite.nl --> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" /> <meta name="description" value="An example of a fluid/liquid/responsive full window width carousel with the previous and next image truncated on the sides." /> <meta name="keywords" value="example, carousel, full, fluid, liquid, window, width" /> <title>carousel</title> <script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script> <script src="jquery.carouFredSel-6.0.4-packed.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('#carousel').carouFredSel({ width: '100%', items: { visible: 3, start: -1 }, scroll: { items: 1, duration: 1000, timeoutDuration: 5000 }, prev: '#prev', next: '#next', pagination: { container: '#pager', deviation: 1 } }); }); </script> <style type="text/css"> html, body { height: 100%; padding: 0; margin: 0; } body { min-height: 500px; } body * { font-family: Arial, Geneva, SunSans-Regular, sans-serif; font-size: 14px; color: #333; line-height: 22px; } #wrapper1{ background-color: #fff; width: 1000px; height: 400px; overflow: hidden; position: relative; margin: 100px auto 0 auto; } #wrapper2 { background-color: #fff; width: 1000px; height: 400px; margin-top: -225px; overflow: hidden; position: absolute; top: 50%; left:0; } #carousel img { display: block; float: left; left: -495px; } #prev { background-color: rgba(255, 255, 255, 0.7); display: block; height: 400px; width: 50%; top: 0; position: absolute; } #next { background-color: rgba(255, 255, 255, 0.7); display: block; height: 400px; width: 50%; top: 0; position: absolute; } #prev:hover, #next:hover { background-color: #fff; background-color: rgba(255, 255, 255, 0.8); } #prev { left: -320px; } #next { right: -320px; } #pager { margin-left: -320px; position: absolute; left: 50%; bottom:0; } #pager a { background-color: #251d18; display: inline-block; width: 128px; height: 6px; margin: 0 auto -6px auto; } #pager a:hover { background-color: rgba(255, 255, 255, 0.5); } #pager a span { display: none; } #pager a.selected { background-color: #aea69d; } </style> </head> <body> <div id="wrapper1"> <div id="wrapper2"> <div id="carousel"> <img src="img/1.jpg" alt="1" width="640" height="400" /> <img src="img/2.jpg" alt="2" width="640" height="400" /> <img src="img/3.jpg" alt="3" width="640" height="400" /> <img src="img/4.jpg" alt="4" width="640" height="400" /> <img src="img/5.jpg" alt="5" width="640" height="400" /> </div> <a href="#" id="prev" title="Show previous"> </a> <a href="#" id="next" title="Show next"> </a> <div id="pager"></div> </div> </div> </div> </body> </html>