CSS3怎么让字体不换行
在css中,可以使用white-space属性来强制文字不换行;通常我们使用white-space:nowrap来强制文本文字内容不换行,文本会在在同一行上显示,直到遇到 <br> 标签为止。
white-space属性设置或检索对象内文本显示方式。
语法:
white-space : normal | nowrap;
属性值:
-
normal:默认。空白会被浏览器忽略。
-
nowrap:文本不会换行,文本会在在同一行上继续,直到遇到 <br> 标签为止。
示例:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> div { width: 120px; height: 60px; line-height: 20px; border: 1px dashed #ccc; margin: 10px; } .demo { white-space: nowrap } </style> </head> <body> <div>内容将会不被换行显示</div> <div class="demo">内容将在一行内强制显示完整</div> </body> </html>
效果图:
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)