css variablen?

Seite 1 von 1 - Forum: Coding Stuff auf overclockers.at

URL: https://www.overclockers.at/coding-stuff/css_variablen_49224/page_1 - zur Vollversion wechseln!


h4de5 schrieb am 22.09.2002 um 20:50

gibts in css irgendeine moeglichkeit werte, zBsp: farben, in variablen zu schreiben? damit man beim aendern nicht immer alle farben ausbessern muss, sondern eben nur einmal den variablen wert?
falls es sowas nicht gibt: weis wer a workaround für sowas?


Tex schrieb am 22.09.2002 um 21:14

du kannst es mit einer serverseitigen programmiersprache lösen (zb php). nur mit css geht es nicht.


h4de5 schrieb am 22.09.2002 um 21:41

wie kann ich das mit php machen?


hempboy schrieb am 22.09.2002 um 21:44

Du legst dir ne Datei an (PHP) und legst dort alle Farben fest...

Code:
$bgcolor = "#000000";
Dann machst die CSS Datei auf, oder die HTMl-Datei wo der CSS-Stuff drinne ist und includest...
Code:
include("phpdatei.php");
<style>
body {color: $color;};
</style>

//edit: Das ist nur damit du den Sinn versteht, nicht den Code übernehmen, sind sicher Bugs drinne!


Ezekiel schrieb am 22.09.2002 um 21:44

nicht schnell genug :(


watchout schrieb am 22.09.2002 um 21:46

Zitat von h4de5
wie kann ich das mit php machen?
<?php
$comcolor='#111111';
?>

<style type="text/css">
body {color:<?=$comcolor ?>;}
a {color:<?=$comcolor ?>;}
</style>

oder
<?php
$comcolor='#111111';
echo <<<EOS
<style type="text/css">
body {color:$comcolor;}
a {color:$comcolor;}
</style>
EOS;
?>


watchout schrieb am 22.09.2002 um 21:48

was heisst nicht schnell genug???


hempboy schrieb am 22.09.2002 um 22:11

Er meint nur das ich ihn ge0wnt habe :D


schrieb am 22.09.2002 um 22:15

wieso sollt das nicht mit pure css gehen :confused:


h4de5 schrieb am 22.09.2002 um 22:23

Zitat von .deRElict.
wieso sollt das nicht mit pure css gehen :confused:

bitte erkär das näher!

@watchout: genau sowas hätt ich gsucht, aba des geht ned wenn ich eine eigene .css datei hab, oda doch?


schrieb am 22.09.2002 um 22:37

class oder id verwenden ;)


watchout schrieb am 23.09.2002 um 19:01

ganz simpel:
#filename:
css.php

#und im css-file (.php) halt so:
<?php
$comcolor='#111111';
?>
body {color:<?=$comcolor ?>;}
a {color:<?=$comcolor ?>;}

(oder die andere version halt ohne style-tags)

#im html:
<link rel='stylesheet' type='text/css' href='css.php'>

edit: wenn du vollzugriss auf den webserver hast kannst auch einstellen welche endungen mit php geparsed werden und einfach .css eintragen, is' aber meistens net so gscheit ;)

und wenns doch net funkt - bitte net haun... :rolleyes:




overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2026