<!doctype html> <html> <head> <meta charset="utf-8"> <title>溢出属性</title> <style> div{ width:200px; height: 200px; background-color: yellow; /*white-space: nowrap; /*overflow: visible;*//*显示溢出*/ /*overflow: hidden;*//*溢出隐藏,文本裁切*/ /*overflow: scroll;*//*有没有溢出都会显示滚动条*/ overflow: auto;/*自动设置,超出范围会出现滚动条,没超出范围不会出现滚动条*/ /*overflow:inherit;*//*继承父元素的效果*/ /*overflow-y: auto;*/ /*overflow-x:hidden;*/ } /*空余空间*/ /* 说明: 该属性用来如何处理元素的的空白) wite-space:norwrap默认值,空白会被游览器忽略, wite-space:wrap文本不会换行,文本会在同一行继续,直到遇到<br>标签为止; wite-space:pre显示空格,回车,换行 wite-speace:pre-wrap:显示空格,回车,换行 wite-speace:pre-line:显示回车,不显示空格,换行 */ /*3、省略号显示 说明: text-overflow:clip/ellipsis; clip:默认值,不显示省略号(..); ellipsis:显示省略标记; 当单行文本溢出显示省略号需要同时设置以下声明: 1、容器宽度:width:200px; 2、强制文本在一行内显示:white-space: nowrap; 3、溢出内容为隐藏:overflow:hidden; 4、溢出文本显示省略号:text-overflow:ellipsis, */ /* <pre> 预格式化文本-保留空格,回车,tab </pre> */ </style> </head> <body> <div>x x x x x x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x </div> </body> </html>