帮忙改段CSS

别样苍茫 2009-06-28 10:11:47
        .style1
{
width: 97%;
}
#shadow
{
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
margin:0px 0px 0px 0px;
width:100%;
height:100%;
background-color:#0060C0;
filter:alpha(opacity=20);
}
#GridViewDIV{
position:absolute;
left:50%;
top:50%;
width:400px;
height:180px;
margin:-90px 0 0 -200px;
border:1px solid #84A0C4;
background-color:#DFE8F6;
text-align:center;
}
.style4
{
height: 80px;
}
.style5
{
height: 6px;
}


希望牛人帮忙改下这段CSS,能兼容IE 6 和 7 及 以上版本
目前在7和8中显示正常,但是对CSS兼容性不是很了解,所以前来求助
...全文
41 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
douzexin1111 2009-06-28
  • 打赏
  • 举报
回复
收藏了,总结了很多的东西啊!
ldryqq 2009-06-28
  • 打赏
  • 举报
回复
zhaoqiliang527 2009-06-28
  • 打赏
  • 举报
回复
帮顶...
yan286093636 2009-06-28
  • 打赏
  • 举报
回复
关注中........
gongsun 2009-06-28
  • 打赏
  • 举报
回复
...
tg01 2009-06-28
  • 打赏
  • 举报
回复
然后就是支持的文件

我把东西打包下

文件路径要自己改咯

http://download.csdn.net/source/1359032
jinemirates 2009-06-28
  • 打赏
  • 举报
回复
其实你要兼容ie6,7,8的话比较简单,再加上一个ff的话就有点困难了,而且在这个里面%的话不好用,最好用具体的数字,这样就不容易出错了,兼容的问题主要是margin 或padding的问题,或者你用并float时有margin的话就会产生双倍距离,因此float的div一定要闭合。根据我以往布css的经验,我帮你写了以下这么一段代码,不知道有没有用,你自己测试一下:
.style1
{
width: 97%;
}
#shadow
{
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
margin:0px 0px 0px 0px;
width:100%;
height:100%;
background-color:#0060C0;
filter:alpha(opacity=20);
}
#GridViewDIV{
position:absolute;
left:50%;
top:50%;
width:400px;
height:180px;
*margin:-45px 0px 0px -100px;
*margin:-45px 0px 0px -100px !important;
margin:-90px 0 0 -200px;
border:1px solid #84A0C4;
background-color:#DFE8F6;
text-align:center;
}
.style4
{
height: 80px;
}
.style5
{
height: 6px;
}

不知道这个有没有用,因为一般我们设div的话像素是具体的,不像你那么粗糙,但还是帮你从网上面找了一些关于兼容的问题,我的网站上面就是用了这些东西才兼容ie和ff有:
1.DOCTYPE 影响 CSS 处理

2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行

3.FF: body 设置 text-align 时, div 需要设置 margin: auto(主要是 margin-left,margin-right) 方可居中

4.FF: 设置 padding 后, div 会增加 height 和 width, 但 IE 不会, 故需要用 !important 多设一个 height 和 width

5.FF: 支持 !important, IE 则忽略, 可用 !important 为 FF 特别设置样式

6.div 的垂直居中问题: vertical-align:middle; 将行距增加到和整个DIV一样高 line-height:200px; 然后插入文字,就垂直居中了。缺点是要控制内容不要换行

7.cursor: pointer 可以同时在 IE FF 中显示游标手指状, hand 仅 IE 可以

8.FF: 链接加边框和背景色,需设置 display: block, 同时设置 float: left 保证不换行。参照 menubar, 给 a 和 menubar 设置高度是为了避免底边显示错位, 若不设 height, 可以在 menubar 中插入一个空格。

9.在mozilla firefox和IE中的BOX模型解释不一致导致相差2px解决方法: div{margin:30px!important;margin:28px;}注意这两个margin的顺序一定不能写反,据阿捷的说法! important这个属性IE不能识别,但别的浏览器可以识别。所以在IE下其实解释成这样: div{maring:30px;margin:28px}重复定义的话按照最后一个来执行,所以不可以只写margin:XXpx! important;

11.ul标签在Mozilla中默认是有padding值的,而在IE中只有margin有值所以先定义 ul{margin:0;padding:0;}就能解决大部分问题

注意事项:

1、float的div一定要闭合。

2、margin加倍的问题
设置为float的div在ie下设置的margin会加倍。这是一个ie6都存在的bug。

解决方案是在这个div里面加上display:inline;

例如:

<#div id=”imfloat”></#div>

相应的css为

#IamFloat{

float:left;

margin:5px;/*IE下理解为10px*/

display:inline;/*IE下再理解为5px*/}

3、关于容器的包涵关系

很多时候,尤其是容器内有平行布局,例如两、三个float的div时,宽度很容易出现问题。在IE中,外层的宽度会被内层更宽的div挤破。一定要用Photoshop或者Firework量取像素级的精度。

4、关于高度的问题

如果是动态地添加内容,高度最好不要定义。浏览器可以自动伸缩,然而如果是静态的内容,高度最好定好。(似乎有时候不会自动往下撑开,不知道具体怎么回事)

5、最狠的手段 - !important;

如果实在没有办法解决一些细节问题,可以用这个方法.FF对于”!important”会自动优先解析,然而IE则会忽略.如下 .tabd1{

background:url(/res/images/up/tab1.gif) no-repeat 0px 0px !important; /*Style for FF*/

background:url(/res/images/up/tab1.gif) no-repeat 1px 0px; /* Style for IE */}值得注意的是,一定要将xxxx !important 这句放置在另一句之上,上面已经提过

IE7.0出来了,对CSS的支持又有新问题。浏览器多了,网页兼容性更差了,疲于奔命的还是我们 ,为解决IE7.0的兼容问题,找来了下面这篇文章:

现在我大部分都是用!important来hack,对于ie6和firefox测试可以正常显示,但是ie7对!important可以正确解释,会导致页面没按要求显示!搜索了一下,找到一个针对IE7不错的hack方式就是使用“*+html”,现在用IE7浏览一下,应该没有问题了。

现在写一个CSS可以这样:

#example { color: #333; } /* Moz */

* html #example { color: #666; } /* IE6 */

*+html #example { color: #999; } /* IE7 */

那么在firefox下字体颜色显示为#333,IE6下字体颜色显示为#666,IE7下字体颜色显示为#999
cs78799662 2009-06-28
  • 打赏
  • 举报
回复
@tg01
速度真够快的
tg01 2009-06-28
  • 打赏
  • 举报
回复
首先,是希望弹框的窗体代码


<table class="item replyPost" style="border: medium none; margin: 0pt;" cellspacing="1">
<tr>
<td class="main">

<script type="text/javascript" src="../Js/Globals1.js"></script>

<!-- Dialog用的html -->
<div id="MzBehaviorDragLayer" onmousemove="mousemovehandler(event)" onmouseup="mouseuphandler(event)"
style="border: medium none; margin: 0px; padding: 0px; z-index: 65000; cursor: move;
position: absolute; height: 420px; width: 400px; background-image: url(Orz/blank.gif);
left: 242px; top: 32px; display: none;">
</div>
<div id="lockwindow" style="border: medium none; margin: 0pt; padding: 0pt; z-index: 1;
left: 0px; top: 0px; height: 3000px; width: 3000px; position: absolute; background-color: rgb(153, 153, 153);
background-image: url(Orz/blank.gif); display: none;">
</div>
<div id="MzForm_mz_i" class="MzForm focused" style="position: absolute; z-index: 56001;
top: 32px; left: 242px; clip: rect(auto, auto, auto, auto); width: 400px; height: 420px;
display: none;" att_mzbehavior_drag="mz_j">
<div class="InnerMzForm png">
<div id="MzFormLayer_mz_i" class="MzFormLayer">
<table id="MzFormLayerTable_mz_i" class="MzFormLayerTable" border="0" cellspacing="0">
<tr>
<td style="background-image: url(../Img/icon.gif);" onmousedown="mousedownhandler(event)"
id="MzFormCaption_mz_i" class="MzFormCaption" onselectstart="return false">
<div id="MzFormControlBar_mz_i" class="MzFormControlBar">
</div>
<div id="MzFormCaptionText_mz_i" class="MzFormCaptionText">
请登陆</div>
</td>
</tr>
<tr>
<td>
<div style="overflow: visible; width: 368px; height: 360px;" id="MzFormContent_mz_i"
class="MzFormContent">
<iframe allowtransparency="true" name="MzForm" style="width: 100%; height: 100%;
display: block;" src="" frameborder="0" scrolling="auto"></iframe>
<div style="width: 100%; height: 100%; display: none;">
</div>
</div>
</td>
</tr>
</table>
</div>
<table style="width: 400px; height: 420px;" id="MzFormBgLayer_mz_i" class="BgLayer"
onselectstart="return false" border="0" cellpadding="0" cellspacing="0">
<tr class="top">
<td class="corner left">
 
</td>
<td class="vertical center">
 
</td>
<td class="corner right">
 
</td>
</tr>
<!-- 如果注释掉就是残缺美,如果不注释那么就是狗啃
<tr class="middle">
<td class="horizontal left"> </td>
<td class="midland center">
<div class="normal"> </div>
<div class="focused"> </div>
</td>
<td class="horizontal right"> </td>
</tr>
-->
<tr class="bottom">
<td class="corner left">
 
</td>
<td class="vertical center">
 
</td>
<td class="corner right">
 
</td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</table>

<script type="text/javascript" src="/Js/ModelDialog.js"></script>

<script type="text/javascript">
function openDialog(dialogUrl, dialogTitle, dialogWidth, dialogHeight) {
showWindow({ url: dialogUrl, width: dialogWidth, height: dialogHeight, title: dialogTitle, top: 100 });
}
function openLoginDialog() {
openDialog('BusinessLogin.aspx', '请登陆', 387, 360)
}
</script>

<script type="text/javascript">
openLoginDialog()
</script>


tg01 2009-06-28
  • 打赏
  • 举报
回复
-0-

你说的这个效果我弄过,是从CSDN拆下来的,我找找看
teerhu 2009-06-28
  • 打赏
  • 举报
回复
路过,帮顶
别样苍茫 2009-06-28
  • 打赏
  • 举报
回复
这段CSS主要是想实现弹出一个DIV,给用户登录,背景变灰,父窗体不能操作,
但是在IE6下面达不到这种效果。。。
tg01 2009-06-28
  • 打赏
  • 举报
回复
这段CSS在IE6里面显示不正常?

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧