zoukankan      html  css  js  c++  java
  • margin-left:auto;margin-right:auto; 不起作用的原因

    1.  是否添加

    过渡的(Transitional):要求非常宽松的DTD,它允许你继续使用HTML4.01的标识(但是要符合xhtml的写法),完整代码如下:

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

    2. 

    .divCenter {
    /* float: left; */
    225px;
    margin-left: auto;
    margin-right: auto;
    }

    请设置元素宽度, 不要增加float属性。

    例子如下直接使用就是居中

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <style>
    .divCenter {
    /* float: left; */

    display:block;

    325px;
    height:200px;
    margin-left: auto;
    margin-right: auto;
    background:#eee;
    }
    </style>

    <div style='float:left;1000px;height:300px;background:#666;'>
    <div class='divCenter'></div>
    </div>

  • 相关阅读:
    MQ的导出备份
    js中this的使用
    wordpress目录文件结构说明
    css3 rem的用法
    初探Backbone
    call 和 apply使用
    公告栏放honehoneclock和喂小老鼠flash
    什么是好单位与坏单位
    常用正则表达式
    gulp入门教程
  • 原文地址:https://www.cnblogs.com/yuzhould/p/12522705.html
Copyright © 2011-2022 走看看