css盒相关样式
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:admin 阅读 404
display:inline-block使元素在一行显示,且能设置高宽,vertical-align设置对齐方式<style>span{display:inline-blockbackgro

display: inline-block;使元素在一行显示,且能设置高宽,vertical-align设置对齐方式

<style>

    span

    {

        display: inline-block;

        background-color: Aqua;

        width: 50px;

        vertical-align:bottom;

    }

</style>

<span>11111</span> <span style="height: 50px">22222</span>

 display:list-item使元素像li方式表示

<style>

    span

    {

        display: list-item;

    }

</style>

<span>11111</span> <span>22222</span>

display: inline-table;使文字与table在同一行

<style>

    table

    {

        display: inline-table;

    }

</style>

<span>11111</span><table>

</table>

<span>22222</span>

text-overflow: ellipsis;使文本超出宽度时以...代替

<style>

    div

    {

        overflow: hidden;//超出部分隐藏

        text-overflow: ellipsis;

        white-space: nowrap;//设置不换行

        width:50px;

    }

</style>

<div>

    sdfsdfsdfsdfsdf</div>

box-shadow:length length length color 分别代表阴影离开文字的横向,纵向距离,模糊半径和阴影颜色,横纵向值为0时在盒周围绘制阴影,支持负值,对第一个文字或第一行可使用选择器first-letter,first-line(如div:first-letter{...})

<style>

    div

    {

        width: 100px;

        height: 100px;

        background-color: AliceBlue;

        -moz-box-shadow: 10px 10px 10px gray;

        -webkit-box-shadow: 10px 10px 10px gray;

    }

</style>

<div>

    sdfsdfsdff</div>

box-sizing:content-box|border-box; content-box表示元素高宽不包括内部补白及边框高宽,border-box表示元素高度包括内部补白及边框高宽

<style>

    div#d1

    {

        box-sizing: content-box;

        width: 200px;

        height: 100px;

        border: 20px solid red;

        margin: 20px;

        padding: 10px;

    }

    div#d2

    {

        box-sizing: border-box;

        width: 200px;

        height: 100px;

        border: 20px solid red;

        margin: 20px;

        padding: 10px;

    }

</style>

<div id="d1">

    sdfsdfsdff</div>

<div id="d2">

    sdfsdfsdff</div>

box-sizing默认为content-box(对内容设置高宽),使用box-sizing可以控制元素的总高宽(border-box),确保div的并列显示

<style>

    div

    {

        box-sizing: border-box;

        width: 50%;

        height: 100px;

        border: 20px solid red;

        padding: 10px;

        float: left;

    }

    div#d2

    {

        border: 20px solid blue;

    }

</style>

<div id="d1">

    sdfsdfsdff</div>

<div id="d2">

    sdfsdfsdff</div>



联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2