前端常用样式控制

 
/*CSS控制表格字数目不溢出,自动省略*/
Table { 
    width: 100%;
    table-layout: fixed; /* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */
}
 Table tr td {
        height: 33px;     
        width: 100%;
        word-break: keep-all; /* 不换行 */
        white-space: nowrap; /* 不换行 */
        overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
        text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用*/
    }

/*控制背景图片自动填充*/
div{
   background-image: url('../images/pop/popbackground.png');
    filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale')";  
    -moz-background-size:100% 100%;  
    background-size:100% 100%; 
}

/*图片加载失败是显示默认图片*/
<img src="'" onerror="this.src='images/weather/晴.png'"/>


/*设置垂直和水平居中*/
   .parentDIV{
        text-align:center;       
    }
    .parentDIV::after, .chirldDIV {
        display: inline-block;
        vertical-align: middle;
    }
    .parentDIV::after {
        content: '';
        height: 100%;
    }

 

posted @ 2018-07-15 15:59  cijian  阅读(348)  评论(0)    收藏  举报