惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
腾讯CDC
D
Docker
G
Google Developers Blog
D
DataBreaches.Net
雷峰网
雷峰网
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
The Cloudflare Blog
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
量子位
美团技术团队
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Engineering at Meta
Engineering at Meta
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - fisherman

学习写第一个SQL server触发器 操纵自如--页面内的配合与通信 一些DIV+CSS 命名规范 asp.net 2.0中生成RSS 避免重复提交 - fisherman - 博客园 button 删除确认 - fisherman - 博客园 用相对定位和负向移动完成图片象框阴影 CSS 代码格式化工具 - fisherman - 博客园 JS代码的格式化和压缩 - fisherman - 博客园 把SQL SERVER里表里的数据导出成为insert into 脚本 对FckEditor编辑器在MAXTHON浏览器下选择服务器文件对话框显示不正常的改进 下载网页中远程图片的方法 读取marc数据 关于ISO2709数据的格式说明 C#写的读取ISO2709格式数据的DLL 数据库打开 使用 Engine 对象创建 SQL Server Compact Edition 数据库 用SharpZipLib压缩和解压缩文件 Access数据库压缩和修复
负边距居中法(水平居中、垂直居中) - fisherman - 博客园
fisherman · 2007-08-30 · via 博客园 - fisherman

本法兼容ie、firefox,opera没试过

<style type="text/css">
.box {
 background-color:#000000;
 color:#ccc;
 width:760px;
 height:500px;
 border:1px solid #ccc;
 position:absolute;
 margin:-250px 0px 0px -380px;
 top:50%;
 left:50%
}
h1 { margin:20px;}
h6 { margin:20px; text-align:right;font-size:14px;}
ol { margin:30px; font-size:14px;}
li { margin:10px;}
</style>

<div class="box">
<h1>负边距居中法(水平居中、垂直居中)</h1>
<ol>
 <li>假定容器宽=760px;高=500px;</li>
 <li>设置容器为绝对定位</li>
 <li>水平居中:a.设置左外边距(margin-left)为-380px; b.50%居左(left:50%)</li>
 <li>垂直居中:a.设置上外边距(margin-top)为-250px; b.50%居上(top:50%)</li>
</ol>
<h6>http://www.happyshow.org</h6>
</div>

来源:http://www.happyshow.org/article.asp?id=102