zoukankan      html  css  js  c++  java
  • 网页开发学习笔记八: css 盒子模型

    • 边框 border
      • border-top-style: solid;   实线

                    dotted;  点绩

                    dashed; 虚线 

      • border-top-color  边框颜色
      • border-top-width   边框宽度
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
    
            .box{
                width: 300px;
                height: 400px;
                background: #999;
                border-top-style: solid;
                border-top-color: red;
                border-top-width: 5px;
                border-bottom-style: dashed;
                border-bottom-color: green;
                border-bottom-width: 10px;
            }
    
        </style>
    </head>
    <body>
    
        <div class="box">AAAAA</div>
    
    </body>
    </html>
    • 边框的连写属性: 没有顺序要求, 线型为必写项
      • border-top: 5px solid red;
    • 边框合并  border-collapse: collapse;
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
    
            table{
                width: 300px;
                height: 500px;
                border: 1px solid red;
                /*边框合并*/
                border-collapse: collapse;
            }
    
            td{
                border: 1px solid red;
                text-align: center;
            }
    
        </style>
    </head>
    <body>
    
        <table cellspacing="0">
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </table>
    
    </body>
    </html>
    • 获取焦点
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            
            .username{
                /*去掉默认边框*/
                border: 0 none;
                /*去掉选中时边框的状态*/
                outline-style: none;
                background: #ccc;
                border: 1px dashed green;
            }

         .username:foucs{
           background: red;
         }

    </style> </head> <body> </body> </html>
    • 获取光标焦点  label for id
    <babel for="username">用户名:</label>
    <input type="text" class="username" id="username"> <br><br>
    • 内边距 padding
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            
            .box{
      /*        padding-left: 20px;
                padding-right: 30px;
                padding-top: 40px;
                padding-bottom: 40px;*/
                width: 500px;
                height: 300px;
                background: red;
    
                /* 上 下 左 右 各20px */
                padding: 20px;
    
                /* 上 下 20px, 左 右 30px */
                padding: 20px 30px;
    
                /* 上 20px, 左 右 30px, 下 10px */
                padding: 20px 30px 10px;
    
                /* 上 右 下 左 */
                padding: 20px 30 10px 50px;
            }
    
        </style>
    </head>
    <body>
    
        <div class="box">AAAAA</div>
    
    </body>
    </html>
      • 内边距撑大盒子的问题
        • 内边距影响盒子的宽度
        • 边框影响盒子的宽度
        • 盒子宽度 = 定义的宽度 + 边框宽度 + 左右内边距
        • 继承的盒子一般不舍被撑大
    • 外边距 padding
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            .box{
                width: 300px;
                height: 300px;
                background: 4000px;
                margin-left: 30px;
                margin-right: 30px;
                margin-top: 40px;
                margin-bottom: 50px;
    
                // 外边距的连写属性
                margin: 20px 30px 40px, 50px;
            }
            
        </style>
    </head>
    <body>
    
        <div class="box">AAAAA</div>

    </body> </html>
    • 外边距 padding
      • 垂直方向外边距合并
        • 两个盒子垂直, 一个设置上外边距, 一个设置下外边距, 取得设置较大
      • 嵌套的盒子外边距塌陷
        • 给父盒子设置边框
        • 给父盒子 overflew: hidden;    
  • 相关阅读:
    SpringMVC文件上传
    c函数调用过程原理及函数栈帧分析
    《C++游戏开发》笔记十一 平滑动画:不再颤抖的小雪花
    Java学习笔记——IO操作之以图片地址下载图片
    uva 400 Unix ls 文件输出排版 排序题
    【VC++积累】之八、PreTranslageMessage;TranslageMessage;GetMessage和PeekMessage的区别
    uva 331 Mapping the Swaps 求交换排序的map 纯DFS
    uva 10344 23 out of 5 凑运算结果 全排列+dfs
    Java学习笔记——File类文件管理及IO读写、复制操作
    uva 301 Transportation 铁路公司的阳谋 纯dfs暴力
  • 原文地址:https://www.cnblogs.com/fanxiaocong/p/6503032.html
Copyright © 2011-2022 走看看