CSS3中text-overflow支持以...代替超出文本

CSS3中text-overflow支持以...代替超出文本。

  1.div1:默认状态。超出文本默认显示在div外
  2.div2:text-overflow:ellipsis; 使用text-overflow以...代理超出文本
  3.div3:如果文本换行被设置为默认(white-space:normal),不会出现超出文本被替代的情况。所以如果文本是块状结构,不能使用text-overflow替换超出文本
  4.div4:text-overflow:clip; 文本在内边框处被剪切
  5.div5:text-overflow:"###"; 自定义超出文本替换的字符串

测试代码:

复制代码
<!DUCUTYPE HTML>
<html>
    <head>
        <style type="text/css">
            div{
                width: 100px;
                height: 100px;
                margin: 10px;
                border: 1px solid #000;
                float: left;
            }
            #div2{
                white-space:nowrap;
                overflow:hidden;
                text-overflow:ellipsis;
                vertical-align:top;
            }
            #div3{
                overflow:hidden;
                text-overflow:ellipsis;
                vertical-align:top;
            }
            #div4{
                white-space:nowrap;
                overflow:hidden;
                text-overflow:clip;
                vertical-align:top;
            }
            #div5{
                white-space:nowrap;
                overflow:hidden;
                text-overflow:"###";
                vertical-align:top;
            }
        </style>
    </head>
    </body>
        <div id="div1">
            test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 
        </div>
        <div id="div2">
            test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 
        </div>
        <div id="div3">
            test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 
        </div>
        <div id="div4">
            test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 
        </div>
        <div id="div5">
            test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 
        </div>
    <body>
</html>
复制代码

 显示结果:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值