Tài liệu Moving into the 21st Century with Cascading Style Sheets

Thảo luận trong 'Thiết Kế Web' bắt đầu bởi Thúy Viết Bài, 5/12/13.

  1. Thúy Viết Bài

    Thành viên vàng

    Bài viết:
    198,891
    Được thích:
    173
    Điểm thành tích:
    0
    Xu:
    0Xu
    Another tremendously powerful trick you can use with CSS is to specify subclasses and to constrain
    formatting styles to a subset of your tags. For example, imagine a Web page like this:
    <div class=”special”>
    This is a special block and bold words should appear
    differently than they do in regular text.</div>
    <p>
    And this, by contrast, is regular bold text,
    with a little italics tossed in for luck
    and an example of italics within bold.
    </p>
    To specify that only the bold tags within the class special should have a particular style, use
    the format class class (in the example below, notice that the b i sequence changes italics
    within bold sequences only):
    <style type=”text/css”>
    .special b { color: green; font-size: 125%; }
    b i { background-color: yellow; }
    b,i { font-weight: bold; color: blue; }
    </style>
    Look closely to see what’s specified here. Two lines contain a pair of selectors separated by a
    space; on the third line, the selectors are separated by a comma. On the two lines in which a
    space separates the selectors, the second selector is affected only when it falls within the first
    selector. In other words, bold text is green only when the is used within a class=”special”
    block, and the background color is yellow only when the is used within a tag. In the last
    of the three CSS lines, I employ a shorthand to specify that both bold tags and italic tags should
    be in bold with blue text. It’s the same as if I had used b { . } and i { }.
     

    Các file đính kèm: