DIV css 相对父容器 水平、垂直 居中
终于把它写出来了。哈哈
<div style="width:100%;height:100%;position:relative;overflow:hidden;"
><br style="line-height:0;"
/><div style="position:relative;top:50%;left:50%;"><br style="line-height:0;"
/><div style="position:relative;
background-color:Yellow;
height:200px;width:200px;
margin-top:-100px;margin-left:-100px;overflow:auto;"
><br style="line-height:0;"
/><div>
名称:<asp:TextBox runat="server" ID="name"></asp:TextBox>
</div>
<br />
<div>
显示名:<asp:TextBox runat="server" ID="TextBox1"></asp:TextBox>
</div>
</div>
</div>
</div>
前3层DIV是必须的。
如果是IE可以去掉第一层DIV.
下面4个数据:
height:200px;width:200px;
margin-top:-100px;margin-left:-100px;"
必须人工计算。
--以后有时间再写完全自动的布局的css
相关文档:
在使用“float”时,因为“float”是javascript的一个保留字,所以就不能使用style.float,而改成了style.cssFloat(IE使用的是style.styleFloat);
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
this.listDiv01.style.styleFloat = "left";
this.listDiv02.style.styleFl ......
人一旦习惯了某些东西就很难去改,以及各种各样的原因,新的浏览器越来越多,而老的总淘汰不了。增长总是快于消亡导致了浏览器兼容是成了谈不完的话题。说到浏览器兼容,CSS HACK自然而然地被我们想起。今天,我们通常都有一个团队或者将有一个团队的人在一个公司里面做相同的事,需要我们有统一的规范来进行Coding,以方 ......
margin:层的边框以外留的空白
background-color:背景颜色
background-image:背景图片
padding:层的边框到层的内容之间的空白
border:边框
content:内容
步骤一、
分析一个典型的定义div例子:
#sample{
margin:10px;
border: #111 10px solid;
......
逐渐喜欢上padding 虽然它并不完美,任何事物都有两面性,无所谓对错,关键是要用对地方!
padding 和 margin相比较,padding 可以将div 等撑起来占用实际空间,而margin则比较小心。
但是就是padding这点缺帮我解决了一个input 和 submit的对齐问题。 ......