最常用的CSS小把戏(Most used CSS tricks)

  •   2009-07-31/13:29
  • 版权声明:本文版权归原作者所有 译介仅供国内读者参考

    本文概要:最常用的CSS Trick,诸如圆角、首字下沉等等。

    之前有篇译介“8个一句话CSS小诀窍”介绍了8个非常使用的一句话CSS小技巧,这周再给大家带来一篇类似的文章,介绍了一些最常用的CSS Trick,或者叫做CSS小把戏。当然我相信每个设计师都会有一些个人的偏好,我个人对文中的一些小把戏就不太感冒。

    1. 不使用图片的圆角效果

    <div id=”container”>
    <b class=”rtop”>
    <b class=”r1″></b> <b class=”r2″></b> <b class=”r3″></b> <b class=”r4″></b>
    </b>
    <!–content goes here –>
    <b class=”rbottom”>
    <b class=”r4″></b> <b class=”r3″></b> <b class=”r2″></b> <b class=”r1″></b>
    </b>
    </div>

    .rtop, .rbottom{display:block}
    .rtop *, .rbottom *{display: block; height: 1px; overflow: hidden}
    .r1{margin: 0 5px}
    .r2{margin: 0 3px}
    .r3{margin: 0 2px}
    .r4{margin: 0 1px; height: 2px}

    (很多人喜欢运用这样的圆角技巧,但我个人不是很喜欢,虽然不用去做圆角的图片,但是多出的这些tag总觉得很多余)

    2. 样式化列表

    <ol>
    <li>
    <p>This is line one</p>
    </li>
    <li>
    <p>Here is line two</p>
    </li>
    <li>
    <p>And last line</p>
    </li>
    </ol>

    ol {
    font: italic 1em Georgia, Times, serif;
    color: #999999;
    }

    ol p {
    font: normal .8em Arial, Helvetica, sans-serif;
    color: #000000;
    }


    这个效果我也是很喜欢的,可以在序号上应用不同的字体。


    3. 无表格表单

    4. 双引号技巧

    5. 渐变字效果

    6. 垂直居中

    更多内容参见原文

    10. 首字下沉

    <p class=”introduction”> This paragraph has the class “introduction”. If your browser supports the pseudo-class “first-letter”, the first letter will be a drop-cap. </p>

    p.introduction:first-letter {
    font-size : 300%;
    font-weight : bold;
    float : left;
    width : 1em;
    }


    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多