Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

css tauschen

Empfohlene Antworten

Veröffentlicht

Hallo zusammen :WD ,

ich will über einen link die aktuell genutzte CSS-Datei durch eine alternative CSS-Datei tauschen.

So das sich das Design der aktuellen Seite durch klick auf den Link ändert.

z.B:

klick auf link 1.: Seite A sieht blau aus (genutzt wird dann CSS-Datei blau.css)

klick auf link 2.: Seite A sieht gelb aus (genutzt wird dann CSS-Datei gelb.css)

hat da jemand was?? :confused:

soll so funktionieren wie auf dieser seite:

Metrostation

Über die Links:

- Metro

- Cielo

- Grass

wird nur ne andere CSS-Datei genutzt und das Design geändert.

Die Seite ist die selbe.

Habe mir schon den Quellcode der Site angeschaut und versucht den für meine Seite zu nutzen (nur den Teil der für die CSS-Dateien relevant ist).

Aber es geht nicht. :confused:

:(:(:(



<link rel="stylesheet" type="text/css" href="css/blue.css" title="blue" media="screen" />

<link rel="alternate stylesheet" type="text/css" href="css/sand/sand.css" title="sand" media="screen" />


.

.

.

<a id="blue" href="#" onclick="setActiveStyleSheet('blue', 1);return false;" title="Switch to Blue theme" >Blue Skin</a>

<br>

<a id="sand" href="#" onclick="setActiveStyleSheet('sand', 1);return false;" title="Switch to Sand theme" >Sand Skin</a>


wenn du php verwendest, dann würde ich einfach den pfad der css dynamisch ändern,...

naja.. ich kann bisher nur html und css.. dank selfhtml.

laut der beispielsite von oben gehts ja irgendwie nur mit html und css...

wenn ich den Quellcode richtig gelesen habe.

schau doch einfach in sein JS rein ;)

http://www.peamarte.it/02/asset/scripts.js

da steht alles und ja, das is mit javascript gemacht!

aha.... :eek:

Ok, danke..

werde mir mal das genauer anschauen.

Hallo Mr. Brot,

ich mach das immer mit PHP. Ist ganz simpel, kannst du dir mal anschauen:

<?php
if ($_GET[set]==1)
{
setcookie ('style', "rot", time()+31536000,'/', "$_SERVER[SERVER_NAME]", '0');
header("Location: $_SERVER[HTTP_REFERER]");
}

else if ($_GET[set]==2)
{
setcookie ('style', "gruen", time()+31536000,'/', "$_SERVER[SERVER_NAME]", '0');
header("Location: $_SERVER[HTTP_REFERER]");
}
else
{
setcookie ('style', "blau", time()+31536000,'/', "$_SERVER[SERVER_NAME]", '0');
header("Location: $_SERVER[HTTP_REFERER]");
}

?>[/php]

Das ist die Datei, in der das Cookie für das Style gespeichert wird. Die kannst du als style.php abspeichern.

Den Link zum Stylewechsel machst du so:

[php]<a href="style.php?set=1">rot</a>
<a href="style.php?set=2">grün</a>

usw....

und oben bei dem Aufruf der CSS Datei schreibst du

<link rel="stylesheet" type="text/css" href="<?php echo (!$_COOKIE[style])?'rot':$_COOKIE[style] ?>.css" />

@T´Pau:

Danke Dir!

Werde es mal ausprobieren! :)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.