CSS换行不能按预期工作 [英] CSS word-wrap not working as expected

查看:121
本文介绍了CSS换行不能按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在以下示例中无法正常使用字词wrap属性?

Why doesnt word wrap property work properly in the example below?

http ://jsfiddle.net/k5VET/739/

我可以做些什么来确保consectetur这个词的一部分符合第一行本身?

What can i do to ensure that part of the word 'consectetur' fits in the first line itself? I want maximum number of characters to fit in each line.

css是:

#fos { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size:14px;
    font-weight: normal;
    line-height: 18px;
    width: 238px;
    height:38px;
    cursor: pointer;
    word-wrap:break-word;
    border:2px solid; }


推荐答案

使用 :break-all;

#fos { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size:14px;
    font-weight: normal;
    line-height: 18px;
    width: 238px;
    height:38px;
    cursor: pointer;
word-break: break-all;
    border:2px solid; }

LIVE DEMO

这篇关于CSS换行不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆