Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]PHP styl css dla konkretenej przeglądarki
yta
post
Post #1





Grupa: Zarejestrowani
Postów: 201
Pomógł: 3
Dołączył: 10.04.2010

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


Witam mam konieczność skorygowania małych błędów na stronie jeżeli chodzi o przeglądarkę chrome , opera (IMG:style_emoticons/default/smile.gif)
I jedyne co znalazłem na google to coś takiego :
  1. <?php
  2. $x = $_SERVER['HTTP_USER_AGENT'];
  3.  
  4. if(substr_count($x,"chrome")!=0)
  5. { $styl = "chrome"; }
  6.  
  7. echo "";
  8. ?>


Siedze nad tym cały dzień i nie mam pomysłu jak zrobić coś takiego :
Mam styl css .styl { color:black;} /*testowo tak*/
A na chrome i tylko na nim ma być .styl1 { color:red;}

I na każdej przeglądarce : FF ,Opera , IE będę miał tekst koloru czarnego a na chrome czerwonego (IMG:style_emoticons/default/smile.gif)
Jak mam to zroić na podstawie kodu który przedstawiłem dokładnie jak mam to wyświetlić bo nie ogarniam za bardzo (IMG:style_emoticons/default/sad.gif)
Proszę o pomoc..
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
yta
post
Post #2





Grupa: Zarejestrowani
Postów: 201
Pomógł: 3
Dołączył: 10.04.2010

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


Na innym forum podpowiedzili aby zrobić tak:
  1. <?php
  2. $x = $_SERVER['HTTP_USER_AGENT'];
  3. $styl = "undefined";
  4. if(substr_count($x,"Chrome")!=0) $styl = "Chrome";
  5. else if(substr_count($x,"Opera")!=0) $styl = "Opera";
  6. else if(substr_count($x,"MSIE")!=0) $styl = "MSIE";
  7. else if(substr_count($x,"Firefox")!=0) $styl = "Firefox";
  8. ?>
  9.  
  10. <!-- I gdzieś w znaczniku <meta> -->
  11.  
  12. <?php
  13. if ($styl = "Opera") echo '<link rel="Stylesheet" type="text/css" href="style/style_dla_opery.css">';
  14. else if ($styl = "Firefox") echo '<link rel="Stylesheet" type="text/css" href="style/style_dla_firefox.css">';
  15. else if ($styl = "MSIE") echo '<link rel="Stylesheet" type="text/css" href="style/style_dla_msie.css">';
  16. else if ($styl = "Chrome") echo '<link rel="Stylesheet" type="text/css" href="style/style_dla_chrome.css">';
  17. else if ($styl = "undefined") echo '<link rel="Stylesheet" type="text/css" href="style/style_dla_nieznanej_przegladarki.css">';
  18. ?>


I ja zrobiłem tak :

  1.  
  2. <?php
  3. if ($styl = "Chrome") echo '<link rel="Stylesheet" type="text/css" href="css/chrome.css">';
  4. ?>
  5.  
  6. <?php
  7. $x = $_SERVER['HTTP_USER_AGENT'];
  8. $styl = "undefined";
  9. if(substr_count($x,"Chrome")!=0) $styl = "Chrome";
  10. ?>
  11.  


Nie wiem czy umiejscowienie drugiego skryptu ma znaczenie ale dzialła to tak ze na każdej przeglądarce odpala się zawartość pliku chrome.css ...
czyli takowa :
  1. .wyslij { position:relative; top:100px; }


Klasa wyslij istnieje także w innym pliku *css i jest ona dla każdej innej przeglądarki niżeli nadmienione tutaj *chrome
Co jest nie tak ? (IMG:style_emoticons/default/sad.gif) dlaczego to odnosi się do wszystkich przeglądarek ?
Proszę o pomoc..
Go to the top of the page
+Quote Post

Posty w temacie


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: 4.10.2025 - 01:28