Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> jqery zmiana szerokości DIV-a suwakiem
david1990
post
Post #1





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

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


Witam,
Chciał bym zmieniać szerokość diva za pomocą suwaka.
mam coś takiego:

  1. onload = function() {
  2. var $ = function(id) { return document.getElementById(id); };
  3. $('one').oninput = function()
  4. {
  5. $('uno').innerHTML = this.value;
  6. $('due').innerHTML = this.value;
  7.  
  8. };
  9. $('one').oninput(); };
  10.  
  11. </head>
  12.  
  13. <div id="golden">
  14. GOLD
  15. <div id="uno"></div>
  16. </div><div id="suwak"><input type="range" id="one" min="0" max="200" value="100"/></div>
  17. <div id="credits">
  18. CREDITS
  19. <div id="due">&nbsp;</div>
  20. </div>
  21.  
  22. <div id="div1" style="height:30px;border: 1px solid red;"></div>


i chciał bym aby podczas przesuwania suwaka zmieniała się szerokość #div1. Nie mam pojęcia jak to zrobić.
Ktoś podpowie?
Pozdrawiam,
Dawid
Go to the top of the page
+Quote Post
Kshyhoo
post
Post #2





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Może to Ci pomoże.
Go to the top of the page
+Quote Post
david1990
post
Post #3





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

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


Dzięki wielkie, przyglądnąłem się temu ale dalej nie wiem jak podłączyć to pod suwak.
Go to the top of the page
+Quote Post
Kshyhoo
post
Post #4





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Zobacz, czy działa:
  1. <!DOCTYPE html>
  2. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  3. <style type="text/css">
  4. body {
  5. font-family: Sans-Serif;
  6. color:#333;
  7. }
  8.  
  9. #chosen {
  10. border-radius: 10px;
  11. width: 45px;
  12. padding-top: 10px;
  13. padding-bottom: 10px;
  14. background-image: -webkit-linear-gradient(top, #ccc, #300);
  15. background-image: -o-linear-gradient(top, #ccc, #300);
  16. background-image: -moz-linear-gradient(top, #ccc, #300);
  17. text-align: center;
  18. color: #fff;
  19. font-weight :bold;
  20. font-size: large;
  21. margin-left: 40px;
  22. }
  23.  
  24. #slider {
  25. margin-left:10px;
  26. }
  27.  
  28. /*this is only for webkit, not opera*/
  29. input[type='range'] {
  30. -webkit-appearance: none;
  31. padding-left: 2px;
  32. padding-right: 2px;
  33. -webkit-border-radius: 5px;
  34. background-image: -webkit-linear-gradient(top, #000, #333, #0000;
  35. }
  36.  
  37. #picHolder {
  38. width: 250px;
  39. height: 240px;
  40. margin: 10px;
  41. }
  42. <script type="text/javascript">
  43. function updateSlider(slideAmount) {
  44. //get the element
  45. var display = document.getElementById("chosen");
  46. //show the amount
  47. display.innerHTML=slideAmount;
  48. //get the element
  49. var pic = document.getElementById("pic");
  50. //set the dimensions
  51. pic.style.width=slideAmount+"%";
  52. }
  53. </head>
  54.  
  55. <div id="slider">0 <input id="slide" min="0" max="200" step="5" value="100" onchange="updateSlider(this.value)" type="range"> 200</div>
  56. <br>
  57. <div id="chosen">100</div>
  58.  
  59. <div id="picHolder">
  60. <div id="pic" style="height: 30px; border: 1px solid red;"></div>
  61. </div>
  62.  
  63. </body>
  64. </html>
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 23.08.2025 - 04:18