水平排列居中两种方法总结

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>水平排列方法</title>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    </head>
    <body>
        <!--方法一:使用display,margin等-->
        <div class="break-list1">
                <div class="list list1">
                    <img src="img/yx.png" />
                </div>
                <div class="list list2">
                    <img src="img/yx.png"/>
                </div>
                <div class="list list3">
                    <img src="img/yx.png"/>
                </div>
            </div>
            <style type="text/css">
                    .break-list1{width: 100%; text-align: center;}
                    /*.list{width: 33%;display: table-cell; border: none;} *//*仅内容图片大的时候*/
                    .break-list1 .list{width: 32.5%;display: inline-block; border: none;} /*内容图片大、小的时候均可使用*/
                    .break-list1 .list img{width: 100%;}
            </style>
        <!--方法二:使用Float-->
        <div class="break-list">
                <ul>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <li><img src="img/yx.png"/></li>
                    <div class="clear" style="clear:both"></div>
                </ul>
            </div>
            <style type="text/css">
                .break-list{}
                .break-list ul li{width: 33%;height: auto;display: inline-block;border-bottom: 1px solid #dadee8;border-left: 1px solid #dadee8;float: left;}
                .break-list ul li img{width: 100%;height: auto;}
            </style>

    </body>
    <style type="text/css">
        html { font-family: "微软雅黑", Helvetica, STHeiTi, Arial, sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; font-size: 62.5%; }
        body { margin: 0; line-height: 1.5; background-color: white; height: 100%; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

        article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; }
        audio, canvas, progress, video { display: inline-block; vertical-align: baseline; }
        audio:not([controls]) { display: none; height: 0; }
        [hidden], template { display: none; }
        svg:not(:root) { overflow: hidden; }

        a { background: transparent; text-decoration: none; -webkit-tap-highlight-color: transparent; }
        a:active { outline: 0; }
        a:active { color: red; }
        abbr[title] { border-bottom: 1px dotted; }
        b, strong { font-weight: bold; }
        dfn { font-style: italic; }
        mark { background: #ff0; color: #000; }
        small { font-size: 80%; }
        sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
        sup { top: -0.5em; }
        sub { bottom: -0.25em; }
        img { border: 0; vertical-align: middle; }
        hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; }
        pre { overflow: auto; white-space: pre; white-space: pre-wrap; word-wrap: break-word; }
        code, kbd, pre, samp { font-family: "微软雅黑", monospace; font-size: 1em; }

        button, input, optgroup, select, textarea { color: inherit; font: inherit; margin: 0; }
        button { overflow: visible; }
        button, select { text-transform: none; }
        button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; cursor: pointer; }
        button[disabled], html input[disabled] { cursor: default; }
        button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
        input { line-height: normal; }
        input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; }
        input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; }
        input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
        input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
        fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; }
        legend { border: 0; padding: 0; }
        textarea { overflow: auto; resize: vertical; }
        optgroup { font-weight: bold; }

        table { border-collapse: collapse; border-spacing: 0; }
        td, th { padding: 0; }

        html, button, input, select, textarea { font-family: "微软雅黑", Helvetica, STHeiTi, Arial, sans-serif; }
        h1, h2, h3, h4, h5, h6, p, figure, form, blockquote { margin: 0; }
        ul, ol, li, dl, dd { margin: 0; padding: 0; }
        ul, ol { list-style: none outside none; }
        h1, h2, h3 { line-height: 2; font-weight: normal; }
        h1 { font-size: 1.8rem; }
        h2 { font-size: 1.6rem; }
        h3 { font-size: 1.4rem; }
        input::-moz-placeholder, textarea::-moz-placeholder { color: #cccccc; }
        input:-ms-input-placeholder, textarea:-ms-input-placeholder { color: #cccccc; }
        input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #cccccc; }

        * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
    </style>
</html>
时间: 2024-08-04 15:10:10

水平排列居中两种方法总结的相关文章

用CSS实现水平虚线的两种方法

用CSS样式实现水平虚线的两种方法方法一:<br><br><hr size="1" noshade="noshade" style="border:1px #cccccc dotted;"/><br>方法二:<br><br><div style="border-top:1px dashed #cccccc;height: 1px;overflow:hidden

枚举有重复元素的排列的两种方法

我们假设A数组是方案数组,P数组是模板数组. 对于每一种方案,从第一个位置开始放元素,一个一个放. 我们原有的打印全排列的方法是不允许A数组中出现重复元素的,如下代码所示: void dfs(int dp) { if(dp>n) { for(int i=1;i<=n;i++) cout<<a[i]<<" "; ans++; cout<<endl; return; } for(int i=1;i<=n;i++) { if(!vis[i

定位实现水平垂直居中的两种方法(无需计算)

首先给想要居中的元素设置绝对定位,其父元素设置相对定位. 然后,方法一:top,left,right,bottom都设置为0,margin:auto,即可在父元素中水平垂直居中. 方法二:top,left都设置为50%,然后transform:translate(-50%,-50%),如果其他地方也用到了transform并且设置transition容易误伤这里.

关于jquery无间隙水平滚动的两种方法

1.利用scrollLeft方法 1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="Generator" content="EditPlus®"> 6 <meta name="Author" content="&q

div等块级元素居中的两种方法

以下两种方法是针对宽度确定的块级元素而言的 1.设置块级元素CSS属性为: margin: 0 auto: 即左右margin设置为auto. 2.设置块级元素的display为inline(此时要求块级元素包含内容,否则由于内联元素的高度设置不起作用,相当于高度为零,块级元素就无法被看到)或者inline-block. 该块状元素的父级元素CSS设置: text-align:center; 此时会将该块状元素看作text进行居中处理.

利用颜色和形态学两种方法进行车牌区域提取的OpenCV代码

要想提取车牌号,首先你要定位车牌区域嘛,本文分别两种方法用,即颜色和形态学的方法,对车牌区域进行判定.说得是两种方法,其实两种方法并无多大的区别,只是有一步的判断标准不一样而已,你看了下面整理出的的思路就知道两者的区别真的很小了. 方法一:利用颜色提取车牌区域的思路: ①求得原图像的sobel边缘sobelMat ②在HSV空间内利用车牌颜色阈值对图像进行二值化处理,得到图像bw_blue→ ③由下面的判别标准得到图像bw_blue_edge for (int k = 1; k != heigh

设置一个DIV块固定在屏幕中央(两种方法)

设置一个DIV块固定在屏幕中央(两种方法) 方法一: 对一个div进行以下设置即可实现居中. <style> #a{ position: fixed; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: auto; } </style> <!doctype html> <html lang="zh-cn"> <head> <meta charset="UT

在List中找出最大值的两种方法

先说需求:找出一个对象List中,某个属性值最大的对象. 1.定义对象 1 private class A 2 { 3 public int ID { get; set; } 4 5 public string Name { get; set; } 6 } 2.为两种方法定义两个时间段全局变量. 1 private static TimeSpan compare = new TimeSpan(); 2 private static TimeSpan order = new TimeSpan();

div随页面滚动遇顶固定的两种方法(js&amp;jQuery)

一.遇顶固定的例子 我一直以为是某个div或层随屏幕滚动,遇顶则固定,离开浏览器顶部又还原这样的例子其实不少,其实它的名字叫"层的智能浮动效果".目前我们在国内的商业网站上就常常看到这样的效果了.例如淘宝网的搜索结果页的排序水平条,在默认状态时,该工具条是跟随页面滚动的,如下图: 而当我们下拉滚动条,随着页面向下滚动,当此工具条接触到浏览器的上边缘时,这时就会独立出来固定在顶部,不跟随页面滚动而滚动了,如下图: 类似的例子效果我们在别的网站上都有看到过,例如腾讯微博首页上,当我们下拉屏