查看完整版本: CSS常用效果实现方法{不断更新中}

szlinz 2008-4-20 11:24

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

1、CSS、DIV界面垂直与水平居中的写法
[code=CSS]{width:612px; height:470px; margin-top:-235px; margin-left:-306px; position:absolute; top:50%; left:50%;}[/code]

2、两行布局一行固定高度一行自适应满屏
[code=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> [/code]

3、去掉链接虚框方法:样式表法
[code=CSS]a,area { blr:expression(this.onFocus=this.blur()) } /* for IE */
:focus { -moz-outline-style: none; } /* for Firefox */ [/code]

[[i] 本帖最后由 szlinz 于 2008-4-20 11:28 编辑 [/i]]

gwpxjb 2008-4-21 08:39

稍微学习下~~

沧蓝 2008-4-21 16:15

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

margin-top 和 margin-left 的值为长宽值的一半。

caincheung 2008-4-24 14:26

顶一个

shipfriend 2008-4-24 21:22

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还有这种用法啊?没看到过!

shipfriend 2008-4-24 21:23

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

shipfriend 2008-4-24 21:24

修改parsInt换成parseInt

guava 2008-5-12 12:43

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

ambo 2008-7-19 21:32

期待大家继续补充...

yeyunan 2008-9-22 10:51

css不建议使用expression
页: [1]
查看完整版本: CSS常用效果实现方法{不断更新中}