• [网页设计]DIV 垂直 垂直水平 居中


    DIV 垂直 居中



    让div居中对齐 使用margin-left:auto;margin-right:auto; 可以让你的div居中对齐。  .style{margin-left:auto;margin-right:auto;}  缩写形式为:  .style{margin:0 auto;}  数字0 表示上下边距是0。可以按照需要设置成不同的值。 





    <style type="text/css">
     .align-center{
        margin:0 auto; /* 居中 这个是必须的,,其它的属性非必须 */
        500px; /* 给个宽度 顶到浏览器的两边就看不出居中效果了 */
        background:red; /* 背景色 */
         /* 文字等内容居中 text-align:center;*/
    }
    </style>
     
    @Html.Partial("_PartialMenuImg", "../../Images/Sys/test.jpg")
     
    <div ></div>
     
    DIV 垂直水平 居中



    1,关于居中使用css为:position:fixed;left:50%;top:50%;margin-left:width/2;margin-top:height/2;  对于ie6,只能把position:改成absolute; 





     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>水平垂直居中div演示效果</title>
    <style type="text/css">
    .align-center{
    position:fixed;left:50%;top:50%;margin-left:width/2;margin-top:height/2;
    }
    </style>
    </head>
    <body>
    <div >水平垂直居中div演示效果</div>
    </body>
    </html>
     

  • 相关阅读:
    Java注释中TODO/FIXME/XXX的含义
    关于update set from where
    WEB打印控件Lodop
    jQuery自动完成组建Autocomplete
    Java触发器CronTrigger
    JVM知识点
    JAVA_OPTS
    java.lang.NoClassDefFoundError:TagSupport
    $SVN代码版本管理工具的使用
    $Eclipse+Tomcat搭建本地服务器并跑通HelloWorld程序
  • 原文地址:https://www.cnblogs.com/yaoxianzi/p/4259841.html
Copyright © 2020-2023  润新知