Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript][CSS][HTML]Rotator jQuery
Raven1122
post
Post #1





Grupa: Zarejestrowani
Postów: 369
Pomógł: 2
Dołączył: 1.11.2010

Ostrzeżenie: (0%)
-----


Witam,

Przeczytalem ksiazke o jQuery, no i chcialem sprawdzic swoje umiejetnosci w jQuery tworzac prosty rotator obrazow, i napotkalem juz problem (IMG:style_emoticons/default/smile.gif)

A wiec:

Mam takie kodziki:

  1. <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
  2. <link rel="stylesheet" href="style.css" type="text/css" />
  3. </head>
  4.  
  5. <div id="slider">
  6. <ul>
  7. <li><img src="01.jpg" /></li>
  8. <li><img src="02.jpg" /></li>
  9. <li><img src="03.jpg" /></li>
  10. <li><img src="04.jpg" /></li>
  11. <li><img src="05.jpg" /></li>
  12. </ul>
  13. </div>
  14. <div id="controls"></div>
  15. $(document).ready(function(){
  16. var html = "<ol class=\"controls\">";
  17. $('#slider img').each(function(i){
  18. html += "<li>" + (i+1) + "</li>";
  19. });
  20. html += "</ol>";
  21. $('#controls').html(html);
  22. var slides = $('#slider img').length;
  23. var width = $('#slider').width();
  24. $('#slider ul').css("width", slides*width);
  25. $('#slider img').each(function(i) {
  26.  
  27. $('#slider ul').css("left", i*width).delay(800);
  28. });
  29. });
  30. </body>
  31. </html>


i css

  1. #slider{
  2. width:696px; height:241px; overflow:hidden; position:relative;
  3. }
  4.  
  5. #slider ul{
  6. list-style:none; position:absolute; left:0;
  7. }
  8.  
  9. #slider li{
  10. float:left; left:10;
  11. }
  12.  
  13. #slider img{
  14. float:left;
  15. }
  16.  
  17. #controls ol{
  18. list-style:none;
  19. }
  20.  
  21. #controls li{
  22. float:left; width:25px; height:22px; background:#f2f2f2; border:1px #d9d9d9 solid; text-align:center; margin-left:5px; padding-top:3px;
  23. }


Lista z kontrolkami wyswietla sie ladnie od 1 do 5, problem w tym ze po dodaniu position:absolute do #slider ul nie wyswietlaja sie obrazki, i mam problem z przesuwaniem ich. bez position:absolute; wyswietla sie tylko obrazek 1 i nic wiecej.

Czy ktos moze mi pomoc z animowaniem takiego slidera?



refresh
Go to the top of the page
+Quote Post
prawda1234567
post
Post #2





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 14.11.2012

Ostrzeżenie: (20%)
X----


Najprościej stworzyć plik index.php i wykonać go z takim kodem:

  1. unlink('style.css');


To odlinkuje i powinno działać ok (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
Raven1122
post
Post #3





Grupa: Zarejestrowani
Postów: 369
Pomógł: 2
Dołączył: 1.11.2010

Ostrzeżenie: (0%)
-----


na pewno zrozumiales pytanie?
Go to the top of the page
+Quote Post
prawda1234567
post
Post #4





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 14.11.2012

Ostrzeżenie: (20%)
X----


Tak, wszystko powinno działać ale trzeba wykonać takie coś w PHP. Inaczej ci pomóc nie umię.

PS: oczywiśćie do php musisz mieć serwer, nie tak jak html!
Go to the top of the page
+Quote Post
r4xz
post
Post #5





Grupa: Zarejestrowani
Postów: 673
Pomógł: 106
Dołączył: 31.12.2008

Ostrzeżenie: (0%)
-----


opiszę, ponieważ trochę zmian jest do zrobienia:
div - niepotrzebny
ul - tu dajesz position relative, width, height, overflow hidden
ul li - tutaj ustalasz position absolute (element aktualnie wyswietlany ma left 0, cala reszta powiedzmy 9999px

ze skryptem widzę że poradzisz sobie bez problemu (IMG:style_emoticons/default/smile.gif)

PS to tylko jedna możliwość, można też zrobić z np. hide()/show() na li (może nawet i lepsze - z marszy mamy załatwione efekty przejścia między obrazami)
Go to the top of the page
+Quote Post
Raven1122
post
Post #6





Grupa: Zarejestrowani
Postów: 369
Pomógł: 2
Dołączył: 1.11.2010

Ostrzeżenie: (0%)
-----


prosilbym o zbanowanie uzytkownika prawda gdyz tylko wprowadza w blad ludzi i mysli nie nie znam php i nie wiem ze se usune style.css

zastosowalem sie do tych porad no i dalej obrazkow nie widac

nie moge se dalej poradzic

styl css wyglada tak:

  1. #slider{
  2. width:696px; height:241px;
  3. }
  4.  
  5. #slider{
  6. list-style:none; position:relative; overflow:hidden; width:696px; height:241px;
  7. }
  8.  
  9. #slider li{
  10. float:left; position:absolute;
  11. }
  12.  
  13.  
  14. #controls ol{
  15. list-style:none;
  16. }
  17.  
  18. #controls li{
  19. float:left; width:25px; height:22px; background:#f2f2f2; border:1px #d9d9d9 solid; text-align:center; margin-left:5px; padding-top:3px;
  20. }


a js i html tak:

  1. <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
  2. <link rel="stylesheet" href="style.css" type="text/css" />
  3. </head>
  4.  
  5. <ul id="slider">
  6. <li><img src="01.jpg" /></li>
  7. <li><img src="02.jpg" /></li>
  8. <li><img src="03.jpg" /></li>
  9. <li><img src="04.jpg" /></li>
  10. <li><img src="05.jpg" /></li>
  11. </ul>
  12.  
  13. <div id="controls"></div>
  14. $(document).ready(function(){
  15. var html = "<ol class=\"controls\">";
  16. $('#slider img').each(function(i){
  17. html += "<li>" + (i+1) + "</li>";
  18. });
  19. html += "</ol>";
  20. $('#controls').html(html);
  21. var slides = $('#slider img').length;
  22. var width = $('#slider').width();
  23. $('#slider li').css("left", "9999px");
  24. $('#slider li').each(function(i) {
  25.  
  26. $('#slider li').css("left", "" + (i*width) + "px").delay(800);
  27. });
  28. });
  29. </body>
  30. </html>


Zrobilem jeszcze takie cos, ale w rezultacie nie widac obrazkow

  1. $(document).ready(function(){
  2. var html = "<ol class=\"controls\">";
  3. $('#slider img').each(function(i){
  4. html += "<li>" + (i+1) + "</li>";
  5. });
  6. html += "</ol>";
  7. $('#controls').html(html);
  8. var slides = $('#slider img').length;
  9. var width = $('#slider').width();
  10. $('#slider img').css("left", "9999px");
  11. $('#slider img').each(function(i) {
  12. var current=i+1;
  13. $('#slider:nth-child(' + i + ')').css("left","9999px");
  14. $('#slider:nth-child(' + current + ')').css("left","0px").delay(800);
  15. });
  16. });


Ten post edytował Raven1122 14.11.2012, 21:34:10
Go to the top of the page
+Quote Post
b4rt3kk
post
Post #7





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

Ostrzeżenie: (0%)
-----


Cytat(prawda1234567 @ 14.11.2012, 20:35:29 ) *
Tak, wszystko powinno działać ale trzeba wykonać takie coś w PHP. Inaczej ci pomóc nie umię.

PS: oczywiśćie do php musisz mieć serwer, nie tak jak html!


Chyba jesteś nie do końca trzeźwy?
Go to the top of the page
+Quote Post
Raven1122
post
Post #8





Grupa: Zarejestrowani
Postów: 369
Pomógł: 2
Dołączył: 1.11.2010

Ostrzeżenie: (0%)
-----


Moj prblem wciaz nie zostal rozwiazany, po usunieciu overflow:hidden zauwazylem ze obrazki nie ukladaja sie poziomo tylko w pionie. moze to jest problemem?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.12.2025 - 04:24