Annuaire › Code ouvert
Code publié par son auteur, en lecture seule. « Copier dans mon espace » crée un nouveau site à vous (non publié) que vous pouvez modifier librement.
css/style.css · 4.5 Ko
/* ============================================================
Fichier : css/style.css
Rôle : apparence du convertisseur (mobile d'abord).
Dépend de : index.html (les classes utilisées ci-dessous).
------------------------------------------------------------
Méthode « mobile d'abord » : on écrit le style pour un petit
écran, puis on l'enrichit avec @media pour les grands écrans.
============================================================ */
/* ----- 1. Variables de couleur (modifiables en un seul endroit) ----- */
:root {
--fond: #f4f1ea;
--carte: #ffffff;
--texte: #1f2933;
--texte-doux: #4a5560; /* contraste suffisant sur fond clair */
--accent: #0b6e6e; /* vert-bleu de l'océan */
--accent-fonce: #084f4f;
--erreur: #b3261e;
--bordure: #c9c4b8;
--rayon: 10px;
}
/* ----- 2. Réglages de base ----- */
/* border-box : la largeur inclut la bordure et le remplissage.
Sans cela, des champs « à 100 % » débordent et créent un scroll horizontal. */
*, *::before, *::after { box-sizing: border-box; }
body {
margin: 0;
/* Polices du système : pas de police web (aucune ressource externe). */
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
font-size: 1rem;
line-height: 1.5;
background: var(--fond);
color: var(--texte);
}
/* Texte réservé aux lecteurs d'écran (caché visuellement) */
.sr-only {
position: absolute; width: 1px; height: 1px; overflow: hidden;
clip: rect(0 0 0 0); white-space: nowrap;
}
/* ----- 3. En-tête ----- */
.entete { position: relative; background: var(--accent-fonce); color: #fff; }
.entete__image { display: block; width: 100%; height: 130px; object-fit: cover; opacity: .55; }
.entete__texte { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 16px; }
.entete h1 { margin: 0; font-size: 1.5rem; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.entete p { margin: 4px 0 0; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
/* ----- 4. Mise en page ----- */
.page { max-width: 640px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.carte { background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 16px; }
.carte h2 { margin-top: 0; font-size: 1.2rem; }
.aide { color: var(--texte-doux); font-size: .95rem; }
/* ----- 5. Formulaires ----- */
.champ { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
label { font-weight: 600; }
input, select {
font: inherit; padding: 10px; width: 100%;
border: 2px solid var(--bordure); border-radius: 8px; background: #fff; color: var(--texte);
}
/* Une ligne : source | bouton inverser | cible */
.ligne-devises { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; }
.ligne-devises .bouton--discret { margin-bottom: 12px; padding: 10px 12px; }
/* Champ invalide : bordure rouge (la classe est ajoutée par le JavaScript) */
.invalide { border-color: var(--erreur); }
.erreur { color: var(--erreur); font-weight: 600; margin: 0 0 8px; }
.erreur:empty { margin: 0; }
/* ----- 6. Boutons ----- */
.boutons { display: flex; flex-wrap: wrap; gap: 8px; }
.bouton {
font: inherit; font-weight: 700; cursor: pointer;
padding: 10px 16px; border-radius: 8px; border: 2px solid var(--accent);
background: var(--accent); color: #fff;
}
.bouton:hover { background: var(--accent-fonce); }
.bouton--discret { background: #fff; color: var(--accent-fonce); }
.bouton--discret:hover { background: #e6f2f2; }
/* Focus visible : INDISPENSABLE pour qui navigue au clavier */
:focus-visible { outline: 3px solid #b45309; outline-offset: 2px; }
/* ----- 7. Résultat ----- */
.resultat {
margin-top: 16px; padding: 12px; border-radius: 8px;
background: #e6f2f2; border-left: 6px solid var(--accent);
overflow-wrap: anywhere; /* évite qu'un long nombre déborde */
}
.resultat strong { font-size: 1.4rem; display: block; }
/* ----- 8. Tableau ----- */
.tableau-defilant { overflow-x: auto; } /* le tableau défile seul s'il est trop large, pas la page */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid var(--bordure); text-align: right; }
th:first-child, td:first-child { text-align: left; }
thead th { background: #eef3f3; }
.pied { text-align: center; color: var(--texte-doux); padding: 16px; font-size: .9rem; }
/* ----- 9. Grands écrans ----- */
@media (min-width: 700px) {
.entete h1 { font-size: 2rem; }
.entete__texte { padding: 0 calc((100% - 640px) / 2 + 16px); }
}