How to set a piece of text in a web page so that its width is 62% of the page width and it can wrap automatically? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:14:37
Original
1102 people have browsed it

假设代码如下:


      文本内容  


这个文本内容很长,希望整个网页的宽度就是屏幕的宽度,这个文本内容的宽度是屏幕宽度的62%且能自动换行,该如何处理?


回复讨论(解决方案)



档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档


补充:纯数字跟连续的英文字母不能实现换行,文字跟单词可以了。


档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档无标题文档
Copy after login

自动换行问题,正常字符的换行是比较合理的,而连续的数字和英文字符常常将容器撑大,挺让人头疼,下面介绍的是CSS如何实现换行的方法

对于div,p等块级元素
正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
html

正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义

css
#wrap{white-space:normal; width:200px; }

1.(IE浏览器)连续的英文字符和阿拉伯数字,使用word-wrap : break-word ;或者word-break:break-all;实现强制断行

#wrap{word-break:break-all; width:200px;}
或者
#wrap{word-wrap:break-word; width:200px;}

abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111


效果:可以实现换行

2.(Firefox浏览器)连续的英文字符和阿拉伯数字的断行,Firefox的所有版本的没有解决这个问题,我们只有让超出边界的字符隐藏或者,给容器添加滚动条

#wrap{word-break:break-all; width:200px; overflow:auto;}

abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111


Effect: The container is normal and the content is hidden

For table

1. (IE browser) use table-layout:fixed; to force the width of the table and hide the excess content




abcdefghigklmnopqrstuvwxyz1234567890sssssssssssss


Effect: Hide redundant content

2. (IE browser) use table-layout:fixed; to force the width of the table, The inner td,th uses word-break : break-all; or word-wrap : break-word ;line break






abcdefghigklmnopqrstuvwxyz 1234567890
abcdefghigklmnopqrstuvwxyz 1234567890


Effect: Line wrap

3. (IE browser) Nest div, p, etc. in td, th using the above mentioned div, p line wrapping method

4. (Firefox browser) use table- layout:fixed; enforces the width of the table. The inner td, th uses word-break: break-all; or word-wrap: break-word; to wrap the line, use overflow:hidden; to hide the excess content. Overflow:auto; cannot be used here. Function





abcdefghigklmnopqrstuvwxyz1234567890 abcdefghigklmnopqrstuvwxyz1 234567890< /td>


Effect: Hide more than content

5. (Firefox browser) Embed in td,th Set div, p, etc. using the method mentioned above to deal with Firefox

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template