Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>HTML5</title>
- <style>
- body { margin:0; }
- .wrap {
- width:1000px;
- margin:0 auto;
- }
- header {
- width:100%;
- height:300px;
- background-image:url(images/main.jpg);
- background-position: center;
- }
- nav {
- width:100%;
- height: 50px;
- background-color:rgb(0,0,0);
- }
- nav a {
- padding:0 10px;
- height:50px;
- color:white;
- font-size: 1.7em;
- line-height:50px;
- display:inline-block;
- text-decoration:none;
- }
- nav a:hover {
- background-color:#f00;
- }
- section, aside { float:left; min-height:400px; }
- section { width:640px; }
- aside { width:360px; }
- footer {
- clear:both;
- width:100%;
- height: 50px;
- line-height: 50px;
- color: white;
- text-align: center;
- background-color:#000;
- }
- .slide {
- position:relative;
- width:640px;
- height:480px;
- margin:10px 0;
- overflow:hidden;
- }
- .slide > img {
- position: absolute;
- width: 640px;
- height: 480px;
- left: -640px;
- top: 0;
- }
- </style>
- </head>
- <body>
- <div class="wrap">
- <header></header>
- <nav>
- <a href="#">HOME</a>
- <a href="#">JavaScript</a>
- <a href="#">CSS</a>
- <a href="#">PHP&MySql</a>
- </nav>
- <div class="main">
- <section>
- <article class="slide">
- <img src="images/1.jpg">
- <img src="images/2.jpg">
- <img src="images/3.jpg">
- <img src="images/4.jpg">
- <img src="images/5.jpg">
- </article>
- <p>
- <button class="prevnext" data-dir="prev">이전</button>
- <button class="prevnext" data-dir="next">다음</button>
- <button class="prevnext" data-dir="up">위로</button>
- <button class="prevnext" data-dir="down">아래로</button>
- </p>
- </section>
- <aside>
- </aside>
- </div>
- <footer>©2015 유승열 All Rights Reserved</footer>
- </div>
- <script src="http://code.jquery.com/jquery-latest.js"></script>
- <script>
- var sno = 0;
- var slides = $(".slide > img");
- var max = slides.length - 1;
- $( slides[sno] ).css("left","0");
- var isAnimating = false;
- $(".prevnext").click(function(){
- if( isAnimating == true ) return;
- isAnimating = true;
- var dir = $(this).attr("data-dir");
- var initLeft = 0;
- var initTop = 0;
- var toLeft = 0;
- var toTop = 0;
- var endLeft = 0;
- var endTop = 0;
- var num = 0;
- if( dir == "next" ) {
- initLeft = "-640px";
- initTop = 0;
- toLeft = 0;
- toTop = 0;
- endLeft = "640px";
- endTop = 0;
- num = 1;
- } else if( dir == "prev" ) {
- initLeft = "640px";
- initTop = 0;
- toLeft = 0;
- toTop = 0;
- endLeft = "-640px";
- endTop = 0;
- num = -1;
- } else if( dir == "up" ) {
- initLeft = 0;
- initTop = "480px";
- toLeft = 0;
- toTop = 0;
- endLeft = 0;
- endTop = "-480px";
- num = 1;
- } else if( dir == "down" ) {
- initLeft = 0;
- initTop = "-480px";
- toLeft = 0;
- toTop = 0;
- endLeft = 0;
- endTop = "480px";
- num = -1;
- }
- for( var i = 0; i <= max; i++){
- if( i != sno ) {
- $(slides[i]).css({"left":initLeft,"top":initTop});
- }
- }
- //현재 보이는 이미지 애니메이션
- $( slides[sno] ).animate({"left":endLeft,"top":endTop},2000,function(){
- $(this).css({"left":initLeft,"top":initTop});
- });
- sno = sno + num;
- if( sno > max ) sno = 0;
- if( sno < 0 ) sno = max;
- //새로 나타날 이미지 애니메이션
- $( slides[sno] ).animate({"left":toLeft,"top":toTop},2000,function(){ isAnimating=false; });
- });
- //var timer = setInterval(function(){ $(".next").click(); },2000);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement