Tabellen Formatierung mit CSS

  • Ich würde gerne zwei verschiedene Tabellen-Layouts nutzen.

    Ein schlichtes nur mit Linien und eines mit jedem zweiten Feld in einer anderen Farbe.

    Ich habe mal versucht ein CSS zu erstellen, aber irgendwie bin ich zu blöde.

    table { width: 100%; margin-bottom: 2px; margin-bottom: 0.015rem; border-left: 2px solid #848484; border-top: 2px solid #848484; border-bottom: 2px solid #848484; font-size: 12px; }
    td, th { padding: 2px 2px; padding: 0.015rem 0.015rem; border-right: 2px solid #848484; border-bottom: 2px solid #848484; border-top: 2px solid #848484; border-left: 2px solid #848484; }
    th { background-color: #f9f9f9; color: #000; }
    tr:nth-child(odd) { background: #F2F2F2; }


    table.blank { width: 100%; margin-bottom: 2px; margin-bottom: 0.015rem; border-left: 2px solid #848484; border-top: 2px solid #848484; border-bottom: 2px solid #848484; font-size: 12px; }
    table.blank td, th { padding: 2px 2px; padding: 0.015rem 0.015rem; border-right: 2px solid #848484; border-bottom: 2px solid #848484; border-top: 2px solid #848484; border-left: 2px solid #848484; }

    Kann da jemand helfen?

    • Anzeige

    Hallo!

    Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.

    • ✔️ Schnelle Ladezeiten (optimiert für WordPress & Co.)
    • ✔️ Deutsche Server & DSGVO-konform
    • ✔️ Persönlicher Support (kein 0815-Ticket-System)

    Mehr erfahren

  • versuch es mal so:

    Code
    table.blank { width: 100%; margin-bottom: 2px; margin-bottom: 0.015rem; border-left: 2px solid #848484; border-top: 2px solid #848484; border-bottom: 2px solid #848484; font-size: 12px; }
    table.blank td, [COLOR=#ff0000]table.blank[/COLOR] th { padding: 2px 2px; padding: 0.015rem 0.015rem; border-right: 2px solid #848484; border-bottom: 2px solid #848484; border-top: 2px solid #848484; border-left: 2px solid #848484; }
    [COLOR=#ff0000]table.blank tr:nth-child(odd) { background: transparent; }[/COLOR]


    Du musst halt für die normale "blank" auch ein background für tr bestimmen, sonst zieht er diesen aus "table".

    Das Geheimnis des Könnens liegt im Wollen!
    [size=12]Bitte keine Hilfegesuche per PN (auch keine "privaten" Links). Das ist ein öffentliches Forum.[/SIZE]

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!