分类

最新评论

Kevin's Blog
.
不管你来或不来,我都在这里--- my country of freedom.
2024
如果人生是值得的,那就值得记录…

六月 廿二 甲辰【龙】年
辛未月 壬辰日 
Sat,27 Jul 2024 14:37:21
自由国度 平凡的足迹
Wed, 14 May 2014 5

在网页的布局过程中,我用min-width设置了一个最小宽度,ff下面显示正常,但是ie6却不识别,在网上找到一个方法:
width:e-xpression(document.body.clientWidth < 600? "600px": "auto" );
可是效果不尽理想,把浏览器宽度慢慢缩小后,居然浏览器就没有响应了,很是郁闷,不知道哪位高手可以给出一个比较完美的解决方法呢?
没响应是问题你的表达式造成的死循环,你忽略了width等于600px的情况。
要让FF和IE下都正常可以写:
width:expression(document.body.clientWidth <= 600? "600px": "auto" );
min-width:600px;

完整演示代码(FF/IE6/IE7测试通过):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试页</title>
<style type="text/css">
body{ margin:0 auto }
#wrap{
height:300px; margin:0 auto; background:#ccc;
width:expression(document.body.clientWidth <= 600? "600px": "auto" );
min-width:600px;
}
</style>
</head>

<body>
<div id="wrap">

</div>

共有0条留言

154368