中文/英文换行总结

html部分

<div class="parent">
        <p class="p1">
            湿哒哒大的大大大的大的大大大的大的啊啊大大大啊大大打啊打大大大
        </p>
        <p class="p2">
            湿哒哒大的大大大的大的大大大的大的啊啊大大大啊大大打啊打大大大
        </p>
        <p class="p3">
            In the usual web development process, by default, long words at the end of the line will open the container, not what we want, what we want should be that the container cannot be opened, and the complete word cannot be forcibly opened, if If the end of the line is a long word, the entire word is wrapped to the next line, just like the word, can automatically wrap, neither support the container, nor force the end of the word, and does not hide the extra letters of the end of the word
        </p>
</div>

css部分

<style>
        .parent{
            width:300px;
            margin:30px auto;
            border:1px solid #000;
            padding:20px 0;
        }
        .p1{
            /*white-space:normal;     !*默认换行*!*/
            white-space:nowrap;     /*强制不换行*/
        }
        .p2{
            white-space: nowrap;        /*不换行并显示省略号*/
            text-overflow:ellipsis;
            overflow:hidden;
        }
        .p3{
            word-wrap:break-word;       /*以单词作为换行依据,换行之后不拆分单词*/
            text-align: justify;
            text-indent:2em;            /*缩进两个字符*/
        }
</style>

文字容器必须要有宽度才能换行

以下是代码效果:

 附上作者链接:

http://dditblog.com/itshare_487.html

转载于:https://www.cnblogs.com/jrxiang/p/11269106.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值