Make long characters automatically wrap (such as URLs and email addresses) Purpose: Make very long strings wrap automatically, but do not break short words in the middle.
Here's how:
- <style>
- div{
- width:300px;overflow:hidden;/* for FF,Opera, fixed width; hide extra characters*/
- word-wrap:break-word;word-break:normal;/* for IE, Safari, supports automatic line wrapping*/
- }
- </ style >
|
You can run the following code in IE, Firefox, Opera, and Safari respectively to see:
- < style type = "text/css" >
- div{width:200px;background:red;overflow:hidden;word-wrap:break-word;word-break:normal;}
- </ style >
- < div > congratulations
- Wrap long characters (such as URLs and email addresses):
- http://www.div-css.com/html/standard/base/81857.html
- SDFG SOME word has spacing...
- XXXXXXXXXXXXDGXXXXXXXXYYYYDFGYYXXXXXXXSDGXXXXXXXXXXXXyXXXXXXXXXXxwhite-space: nowrap
- Some Chinese fonts Some Chinese fonts Some Chinese fonts Some Chinese fonts Some Chinese fonts Some Chinese fonts, may not wrap
- Web standardization < a href = "http://www.div-css.com" _fcksavedurl = "http://www.div-css.com" > www.div-css.com </ a >
- Chinese characters Chinese characters Chinese characters Chinese english characters Chinese characters Chinese english characters Chinese english characters Chinese english characters Chinese english characters Chinese english characters Chinese english characters Chinese english characters
- </div>
|
In addition, as for the method on the Internet of using JS to automatically wrap long strings in Firefox, it is not recommended. The reason is that the string obtained after wrapping is no longer the original string. For example, if it is a link address, If you copy it again, you will no longer get the original address, and there will be a space in the middle. That is already another link.