Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 29
  1. #1

    10 modi per utilizzare e snellire i css

    In questo articolo sono illustrate dieci semplici dritte per l'uso dei css e per snellire il codice degli stessi:

    - http://www.evolt.org/article/Ten_CSS...369/index.html

    I primi due sono sicuramente i più interessanti.
    1. CSS font shorthand rule

    When styling fonts with CSS you may be doing this:
    font-size: 1em;
    line-height: 1.5em;
    font-weight: bold;
    font-style: italic;
    font-variant: small-caps;
    font-family: verdana,serif;

    There's no need though as you can use this CSS shorthand property:
    font: 1em/1.5em bold italic small-caps verdana,serif

    Much better! Just a couple of words of warning: This CSS shorthand version will only work if you're specifying both the font-size and the font-family. Also, if you don't specify the font-weight, font-style, or font-varient then these values will automatically default to a value of normal, so do bear this in mind too.


    2. Two classes together

    Usually attributes are assigned just one class, but this doesn't mean that that's all you're allowed. In reality, you can assign as many classes as you like! For example:
    <p class="text side">...</p>

    Using these two classes together (separated by a space, not with a comma) means that the paragraph calls up the rules assigned to both text and side. If any rules overlap between the two classes then the class which is below the other in the CSS document will take precedence.

  2. #2
    molto interessante, sopratutto la possibilità di assegnare più di una classe per elemento.

  3. #3
    Può snellire di molto le sub-strutture che siamo soliti creare con i div+class o id annidati e inutili...


  4. #4
    Utente di HTML.it L'avatar di Sonikag
    Registrato dal
    Mar 2004
    Messaggi
    2,080
    Domanda su questo:

    ---
    3. CSS border default value
    When writing a border rule you'll usually specify the colour, width and style (in any order). For example, border: 3px solid #000 will give you a black solid border, 3px thick. However the only required value here is the border style.

    If you were to write just border: solid then the defaults for that border will be used. But what defaults? Well, the default width for a border is medium (equivalent to about 3 to 4px) and the default colour is that of the text colour within that border. If either of these are what you want for the border then you can leave them out of the CSS rule!
    ---

    tradotto? non ho capito bene il significato...
    Oltreututto (se non erro) il W3c non accetta #000 ma vuole #000000.

    Sonia

  5. #5
    Ti dice semplicemente che ci sono certe regole che non è necessario ripetere.

    Nel caso del border, il valore di default è:
    border: solid 3px #000;

    Pertanto, inserire questa istruzione per settare il bordo di un elemento con quelle caratteristiche è ridondante. Ragionamento, aggiungo, da estendere a tutti gli elementi.



    P.S. Per il discorso delle abbreviazioni del codice del colore... non saprei. Qualcuno ne sa qualcosa?

  6. #6
    Utente di HTML.it L'avatar di zoom
    Registrato dal
    Dec 2001
    Messaggi
    1,737
    i colori a 3 cifre non dovrebbero dare problemi.
    vengono supportati da tutti i browser più importanti che supportano css2...
    Chicco Ravaglia per sempre con noi!

  7. #7
    E' quello che ho notato sempre anch'io...
    Ora occorre però verificare che sia anche una soluzione w3c standard.

  8. #8
    Utente di HTML.it L'avatar di span
    Registrato dal
    Jan 2004
    Messaggi
    1,644
    sì, viene validato.

    pittosto, sei sicuro che la doppia classe sia crossbrowser?

  9. #9
    Non al cento per cento.

    codice:
    .c {
       color: #fff;
    }
    .b {
       background: #000;
    }
    
    ...
    
     :yuppi: 
    Riesci a provarlo su più browser? Io in ufficio ho solo IE e Volpe di fuoco...

  10. #10
    Utente di HTML.it L'avatar di span
    Registrato dal
    Jan 2004
    Messaggi
    1,644
    si, ma il problema, se non ricordo male, è proprio IE

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.