css自动换行,防止撑破div
动换行问题,正常字符的换行是比较合理的,而连续的数字和英文字符常常将容器撑大,挺让人头疼,下面介绍的是CSS如何实现换行的方法
对于div,p等块级元素
正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
html
<
id="wrap">正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义< /div
>
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;}
<
id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111< /div
>
效果:可以实现换行
2.(Firefox浏览器)连续的英文字符和阿拉伯数字的断行,Firefox的所有版本的没有解决这个问题,我们只有让超出边界的字符隐藏或者,给容器添加滚动条
#wrap{word-break:break-all; width:200px; overflow:auto;}
<
id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111< /div
>
效果:容器正常,内容隐藏
对于table
1.
(IE浏览器)使用 table-layout:fixed;强制table的宽度,多余内容隐藏
< style="table-layout:fixed" width="200">
<>
<>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss
<
/td >
<
/tr >
<
/table >
效果:隐藏多余内容
2.(IE浏览器)使用
table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap :
break-word ;换行
< width="200" style="table-layout:fixed;">
<>
<
width="25%" style="word-break : break-all; ">abcdefghigklmnopqrstuvwxyz
1234567890
<
/td >
<
style="word-wrap : break-word ;">abcdefghigklmnopqrstuvwxyz 1234567890
<
/td >
<
/tr >
<
/table >
效果:可以换行
3.
(IE浏览器)在td,th中嵌套div,p等采用上面提到的div,p的换行方法
4.(Firefox浏览器)使用
table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap :
break-word ;换行,使用overflow:hidden;隐藏超出内容,这里overflow:auto;
相关文档:
应用样式的方法有三种:外部(external)、内部(internal)和内联(inline)。其中前两者的基本格式为:
selector { property : value; }
CSS中可以使用不同的selector(选择符)来应用样 ......
<style type="text/css">
<!--
input{ background:expression((this.readOnly &&this.readOnly==true)?"#CCCCCC":"")}
-->
</style>
<body>
<input type="text" name="" />
<input type="text" name="" readonly="readonly" />
expression:处理方式:
  ......
原文地址:http://www.devwebpro.com/25-rounded-corners-techniques-with-css/
* This post is regularly updated. *
Rounded corners is one of the most popular and frequently requested
CSS techniques even the father of internet Google
also launch the rounded corners style markup
with her Google Ad ......
在前端开发中,我们经常遇到这样的情况:服务器传到前端的图片需要缩小以显示(如下),在将其缩放之后,IE中图片效果不容乐观。
<img class="thumb" src=http://www.webyi.com/wschool/wdesign/CSS/20090905/"pic.jpg" alt="This image is really 500x500 big" width="50" height="50" />
IE7支持自定义双三次&ldq ......