![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 1 640 Pomógł: 28 Dołączył: 13.02.2003 Skąd: Międzyrzecz/Poznań Ostrzeżenie: (0%) ![]() ![]() |
Jak pobrac dane (np. kolor, rozmiar) ze styli w zewnetrznym pliku css?
-------------------- PHP Developer
"Nadmiar wiedzy jest równie szkodliwy jak jej brak" Émile Zola |
|
|
![]() |
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 189 Pomógł: 0 Dołączył: 4.07.2004 Skąd: z neostrady Ostrzeżenie: (0%) ![]() ![]() |
Jeżeli masz już zaimportowany stylesheet, np. pierwszy:
document.styleSheets[0].cssRules[index] - zobacz sobie w DOM Inspector jaka jest struktura Ten post edytował akubiczek 28.04.2006, 22:13:05 |
|
|
![]()
Post
#3
|
|
![]() Grupa: Zarejestrowani Postów: 1 640 Pomógł: 28 Dołączył: 13.02.2003 Skąd: Międzyrzecz/Poznań Ostrzeżenie: (0%) ![]() ![]() |
Cytat(akubiczek @ 2006-04-28 23:12:28) document.styleSheets[0].cssRules[index] Wlasnie doszedlem do tego tez: Kod document.styleSheets[0].cssRules[index].style.fontSize; Ale z tego co widze zamiast `index` nie mozna wpisac nazwy, tylko odwolywac sie trzeba poprzez liczby - co mnie nie zadowala... -------------------- PHP Developer
"Nadmiar wiedzy jest równie szkodliwy jak jej brak" Émile Zola |
|
|
![]()
Post
#4
|
|
![]() Grupa: Moderatorzy Postów: 4 465 Pomógł: 137 Dołączył: 26.03.2004 Skąd: Gorzów Wlkp. ![]() |
Przyłączam się powyższego postu - ja pobrac regułę po jej nazwie?
Dzikeuję i pozdrawiam, -------------------- To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness; chaotic, confused, vulnerability, to inform yourself. Think for yourself. Question authority. |
|
|
![]()
Post
#5
|
|
![]() Grupa: Przyjaciele php.pl Postów: 2 258 Pomógł: 16 Dołączył: 21.09.2004 Skąd: Kielce Ostrzeżenie: (0%) ![]() ![]() |
Przykładowy css:
Kod * { margin: 0; padding: 0; } body { text-align: center; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; } #cont { margin: 0 auto; background-color: black; color:#ffffff; } #head { color:green; } .foot { color:red; } js: Kod function getrule(rule,attr) { var rules = document.styleSheets[0].cssRules; var ct = rules.length; var out = ''; var arr = new Array(); if(attr.indexOf('-') > -1) { arr = attr.split("-"); attr = arr[0].concat(arr[1].slice(0,1).toUpperCase().concat(arr[1].substr(1))); } for(var i = 0; i < ct; i++) { if(rules[i].selectorText == rule) { out = rules[i].style[attr]; } } alert(out); } przykład: -------------------- -------------
------ |
|
|
![]()
Post
#6
|
|
![]() Grupa: Moderatorzy Postów: 4 465 Pomógł: 137 Dołączył: 26.03.2004 Skąd: Gorzów Wlkp. ![]() |
Dzięki za odpowiedź
![]()
Szkoda, ze nie uwzględnili jakiejś prostszej metody na dostęp do tych css'ów :/ Pozdrawiam. -------------------- To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness; chaotic, confused, vulnerability, to inform yourself. Think for yourself. Question authority. |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 19.07.2025 - 04:49 |