![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 26 Pomógł: 0 Dołączył: 18.03.2012 Ostrzeżenie: (0%) ![]() ![]() |
Witam.
Mam skrypcik, podstawowy, nie jestem jQuerowcem jeszcze znanym, ale cos tak kombinuje. Kod <script> $(".one").click(function() { $(".one").toggleClass("active", 300); }); $(".max").click(function() { $(".circle").removeClass("left"); $(".circle").removeClass("right"); $(".circle").removeClass("bottom"); $(".circle").toggleClass("top"); }); $(".min").click(function() { $(".circle").removeClass("left"); $(".circle").removeClass("right"); $(".circle").removeClass("top"); $(".circle").toggleClass("bottom"); }); $(".prev").click(function() { $(".circle").removeClass("right"); $(".circle").removeClass("top"); $(".circle").removeClass("bottom"); $(".circle").toggleClass("left"); }); $(".next").click(function() { $(".circle").removeClass("left"); $(".circle").removeClass("top"); $(".circle").removeClass("bottom"); $(".circle").toggleClass("right"); }); </script> Wyobraźcie sobie iPoda i po kliknieciu np. na pogłośnienie czy ściszenie od strony buttona pojawia się jakiś cień i zaraz znika. Powyższy skrypt daje efekt pojawiania się stylu, dokładnie dodaje mi klase do innej klasy, ale ja chciałbym żeby to było coś na styl :active w html. Czyli chce kliknąć raz i styl pojawi się i zaraz zniknie i tak dalej w nieskończoność... Problem w tym że klasa w którą klikam jest gdzie zagnieżdżona w klasie na której ma się zmieniac styl (w tym przypadku tylko 'box-shadow'. Mógłbym to zrobić na pozycji absolutnej i display:none; ale wolałbym jQuery ![]() Pozdrawiam:) |
|
|
![]() |
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 324 Pomógł: 110 Dołączył: 18.09.2012 Ostrzeżenie: (0%) ![]() ![]() |
Pokaż kod html i css jaki do tego masz a napiszę Ci to a potem wyjaśnię co jak robi
![]() Mała podpowiedz jeżeli chcesz zrobić aby coś Ci się pojawiało a po chwili znikało używasz funkcji delay() na przykład nadajesz klasę do elementu a potem ją automatycznie usuwasz.
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 26 Pomógł: 0 Dołączył: 18.03.2012 Ostrzeżenie: (0%) ![]() ![]() |
Próbowałem z delay(), ale nie działa mi prawidłowo.
HTML: Kod <div class="circle active"> <!-- central logo --> <div class="dribbleLogo"></div> <!-- navigation --> <!-- volume control --> <a href="#"> <div class="volume max"> <span></span> <span></span> </div> </a> <a href="#"> <div class="volume min"> <span></span> </div> </a> <!-- next/prev item --> <div class="nextPlayPrev"> <a href="#"> <div class="prev"> <span></span> <span></span> <span></span> </div> </a> <a href="#"> <div class="playPause"> <span></span> <span></span> <span></span> </div> </a> <a href="#"> <div class="next"> <span></span> <span></span> <span></span> </div> </a> </div> </div> CSS: Kod .circle {
position: absolute; left: 22px; top:20px; .square(174px); background:@white; .border-radius(90px); box-shadow: inset 2px 2px 20px 3px rgba(0,0,0,.2), inset -2px -2px 20px 3px rgba(0,0,0,.2), 1px 1px 5px 1px rgba(255,255,255,.2), -1px -1px 5px 1px rgba(255,255,255,.2); border: 1px solid rgba(0,0,0,.5); &.active { &.top { box-shadow: inset 2px 2px 20px 3px rgba(0,0,0,.2), inset -2px -2px 20px 3px rgba(0,0,0,.2), 1px 1px 5px 1px rgba(255,255,255,.2), -1px -1px 5px 1px rgba(255,255,255,.2), inset 0 3px 1px 2px rgba(0,0,0,.2); } &.right { box-shadow: inset 2px 2px 20px 3px rgba(0,0,0,.2), inset -2px -2px 20px 3px rgba(0,0,0,.2), 1px 1px 5px 1px rgba(255,255,255,.2), -1px -1px 5px 1px rgba(255,255,255,.2), inset -3px 0 1px 2px rgba(0,0,0,.2); } &.bottom { box-shadow: inset 2px 2px 20px 3px rgba(0,0,0,.2), inset -2px -2px 20px 3px rgba(0,0,0,.2), 1px 1px 5px 1px rgba(255,255,255,.2), -1px -1px 5px 1px rgba(255,255,255,.2), inset 0 -3px 1px 2px rgba(0,0,0,.2); } &.left { box-shadow: inset 2px 2px 20px 3px rgba(0,0,0,.2), inset -2px -2px 20px 3px rgba(0,0,0,.2), 1px 1px 5px 1px rgba(255,255,255,.2), -1px -1px 5px 1px rgba(255,255,255,.2), inset 3px 0 1px 2px rgba(0,0,0,.2); } } .dribbleLogo { background: url("@{image-path}/dribble.png") rgba(222,99,158,1) no-repeat; .square(105px); position: absolute; top:35px; left:35px; .border-radius(90px); box-shadow: 6px 6px 20px 3px rgba(0,0,0,.2), -6px -6px 20px 3px rgba(0,0,0,.2); border: 1px solid rgba(0,0,0,.3); } .volume { position: absolute; .square(15px); &.max { top: 15px; left: 80px; } &.min { bottom: 4px; left: 80px; } span { display: block; .size(3px, 15px); .border-radius(5px); background: rgba(178,180,184,1); box-shadow: 0 1px 0 0 rgba(255,255,255,1); &+span { .rotate(90deg); -webkit-transform-origin:60% 10%; -moz-transform-origin:60% 10%; -o-transform-origin:60% 10%; box-shadow: 1px 0 0 0 rgba(255,255,255,1); } } } .nextPlayPrev { a { .prev { position: absolute; top: 80px; left:10px; span { position: absolute; display: block; .size(12px, 2px); background: rgba(178,180,184,1); &+span { .size(0, 0); left:3px; border-right:7px solid rgba(178,180,184,1); border-top: 7px solid transparent; border-bottom: 7px solid transparent; background: none; &+span { left:10px; } } } } .next { position: absolute; top:80px; right:10px; span { position: absolute; display: block; .size(12px, 2px); background: rgba(178,180,184,1); right:-3px; &+span { .size(0, 0); border-left:7px solid rgba(178,180,184,1); border-top: 7px solid transparent; border-bottom: 7px solid transparent; background: none; right: 0; &+span { right:7px; } } } } .playPause { position: absolute; top:76px; left: 67px; span { position: absolute; display: block; .size(0,0); border-left:15px solid rgba(191,192,196,1); border-top: 10px solid transparent; border-bottom: 10px solid transparent; &+span { .size(19px, 6px); background: transparent; border-top: 0; border-bottom: 0; border-left: 4px solid rgba(191,192,196,1); border-right: 4px solid rgba(191,192,196,1); left:25px; } } } } } } |
|
|
![]()
Post
#4
|
|
![]() Grupa: Zarejestrowani Postów: 324 Pomógł: 110 Dołączył: 18.09.2012 Ostrzeżenie: (0%) ![]() ![]() |
Hmm faktycznie delay() nie działa ciekawi mnie tylko czemu. Nie lubie takiego pisania css bo dla mnie jest on troszkę nieczytelny ale nie ważne. Napisałem coś takiego i chyba działa
![]()
Spróbuj jak nie będzie to dla Ciebie optymalne to przerobie tego css i htmla i napisze to bardziej optymalnie ![]() |
|
|
![]()
Post
#5
|
|
Grupa: Zarejestrowani Postów: 26 Pomógł: 0 Dołączył: 18.03.2012 Ostrzeżenie: (0%) ![]() ![]() |
Jesteś wielki, działa!
Struktura CSSa niestety pisana jest w LESS'ie więc jest nieczytelna trochę ![]() Mam jeszcze takie małe pytanko. Czy da się dopisac jakoś do tego aby po przytrzymaniu klawisza myszki efekt też działał ? ![]() ![]() Dzięki wielkie za pomoc! Pozdrawiam! Uporałem się z tym z pomocą pewnej osoby. Kod przedstawia się następująco: Kod // add class for clicked button $(".max").mousedown(function() { $(".circle").addClass("top"); }); $(".prev").mousedown(function() { $(".circle").addClass("left"); }); $(".next").mousedown(function() { $(".circle").addClass("right"); }); $(".min").mousedown(function() { $(".circle").addClass("bottom"); }); // clear all pushed button for ipod $(document).mouseup(function() { $(".circle").removeClass("top"); $(".circle").removeClass("left"); $(".circle").removeClass("right"); $(".circle").removeClass("bottom"); }); $(document).mousemove(function() { $(".circle").removeClass("top"); $(".circle").removeClass("left"); $(".circle").removeClass("right"); $(".circle").removeClass("bottom"); }); // top slide button $(".one").click(function() { $(".one").toggleClass("active", 300); }); Może komuś się przyda ![]() |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 15.06.2025 - 07:51 |