发新话题
打印

CSS常用效果实现方法{不断更新中}

本主题被作者加入到个人文集中

CSS常用效果实现方法{不断更新中}

1、CSS、DIV界面垂直与水平居中的写法
复制内容到剪贴板
CSS 代码:
{width:612px; height:470px; margin-top:-235px; margin-left:-306px; position:absolute; top:50%; left:50%;}
2、两行布局一行固定高度一行自适应满屏
复制内容到剪贴板
HTML 代码:
<!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" c />
<title>高度满屏</title>
<style type="text/css">
html,body{
height:100%;}
body{
padding:0;
margin:0;}
#top{
height:50px;
background-color:#CCC;
color:#fff;}
#autoHeight{
position:absolute;
top:50px;
right:0;
left:0;
bottom:0;
height:expression((document.body.clientHeight - 50) + "px");
width:100%;
background-color:#999;
color:#fff;}
</style>
</head>

<body>
<div id="top">top</div>
<div id="autoHeight">autoHeight</div>
</body>
</html>
3、去掉链接虚框方法:样式表法
复制内容到剪贴板
CSS 代码:
a,area { blr:expression(this.onFocus=this.blur()) } /* for IE */
:focus { -moz-outline-style: none; } /* for Firefox */
[ 本帖最后由 szlinz 于 2008-4-20 11:28 编辑 ]
本帖最近评分记录
  • Hex 威望 +5 原创内容 2008-4-21 09:23

TOP

稍微学习下~~

TOP

对于第一个,补充说明一下:

margin-top 和 margin-left 的值为长宽值的一半。
Fred Wu
thislab.com

TOP

顶一个

TOP

function center(div)
{
     var oDiv = getElementById(div);
     oDiv.style.position="absolute";
     oDiv.style.top = document.body.clientHeight/2 - parsInt(oDiv.style.height/2);
     oDiv.style.left = document.body.clientWidth/2 - parsInt(oDiv.style.width/2);
}

还有那个CSS里面的expression还有这种用法啊?没看到过!

TOP

修改var oDiv = document.getElementById(div);

TOP

修改parsInt换成parseInt

TOP

不错 最近我也想做这个东西
css也可以套一些设计模式啊
设计模式是样好东西 有什么大牛出来讲解下吗?

TOP

期待大家继续补充...

TOP

css不建议使用expression

TOP

expression只能用于ie

TOP

好帖子。。。
CodeIgniter,JQuery,Ext
http://www.girlsgroup.cn

TOP

发新话题