zoukankan      html  css  js  c++  java
  • body背景和居中

    浮动
    1、代码1
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
        <style>
            .container{
                border:solid 1px red;
            }
            .l{
                width: 100px;
                height: 100px;
                background-color: #00ee00;
                border: solid 1px darkblue;
            }
        </style>
    </head>
    <body>
    <div class="container">
        <div class="l">1</div>
        <div class="l">2</div>
        <div class="l">3</div>
        <div class="l">4</div>
        <div class="l">5</div>
        <div class="l">6</div>
        <div class="l">7</div>
        <div class="l">8</div>
    </div>
    </body>
    </html>
    
    

    代码2 

    .container 的宽度塌陷了
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
        <style>
            .container{
                border:solid 1px red;
            }
            .l{
                  width: 100px;
                  height: 100px;
                  background-color: #00ee00;
                  border: solid 1px darkblue;
                  float: left;
              }
        </style>
    </head>
    <body>
    <div class="container">
        <div class="l">1</div>
        <div class="l">2</div>
        <div class="l">3</div>
        <div class="l">4</div>
        <div class="l">5</div>
        <div class="l">6</div>
        <div class="l">7</div>
        <div class="l">8</div>
    </div>
    </body>
    </html>

    
    
    解决浮动塌陷问题: 使用
     .clearflex::after


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
        <style>
            .container{
                border:solid 1px red;
            }
            .clearflex::after{
                content: '';
                display: block;
                clear: both;
            }
            .l{
                  width: 100px;
                  height: 100px;
                  background-color: #00ee00;
                  border: solid 1px darkblue;
                  float: left;
              }
        </style>
    </head>
    <body>
    <div class="container clearflex">
        <div class="l">1</div>
        <div class="l">2</div>
        <div class="l">3</div>
        <div class="l">4</div>
        <div class="l">5</div>
        <div class="l">6</div>
        <div class="l">7</div>
        <div class="l">8</div>
    </div>
    </body>
    </html>

    
    
    背景图片练习 
    <head> <meta charset="UTF-8">

    <title>Title</title>

    <
    style> /*}*/
    body
    { /*body背景特殊*/ /*颜色 url repeat 上边为0 下边为0 撑满*/
    background
    : url("../aa.jpg") no-repeat 0 0/100%; }

    </style>
    </head>
    <body>
    <h1>lorem111</h1>

    <p>lorem2222</p> <div>lorem333</div> </body>

    Body元素的背景

    背景颜色

     

     

     

     

    <style>
    
            html{
                 background-color: #f8efc0;
             }
            /*}*/
            body{
                background:url("../aa.jpg");
                background-repeat: no-repeat;
                background-size: 100%;
            }
    
        </style>
    </head>
    <body>
    <h1>lorem111</h1>
    <p>lorem2222</p>
    <div>lorem333</div>
    </body>

    <style>
    
            /*html{*/
                 /*background-color: #f8efc0;*/
             /*}*/
            /*}*/
            body{
                background:url("../aa.jpg");
                background-repeat: no-repeat;
                background-size: 100%;
            }
    
        </style>
    </head>
    <body>
    <h1>lorem111</h1>
    <p>lorem2222</p>
    <div>lorem333</div>
    </body>

    居中

    行元素使用text-algin:center

  • 相关阅读:
    hibernate怎么做分页
    JS+CSS带数字和左右按钮可控制切换的图片幻灯
    AOP下的权限控制实现
    Hibernate3和MyBatis(iBatis)的执行效率比较
    CKEditor/FCKEditor 使用-CKeditor 3.0.1 快速教程(含插入图片)
    用JS写CSS
    spring aop实现权限控制,路径控制
    sql server 同步复制要点
    千万别把自己当人才
    web.xml元素介绍
  • 原文地址:https://www.cnblogs.com/chenduzizhong/p/11215936.html
Copyright © 2011-2022 走看看