zoukankan      html  css  js  c++  java
  • CSS 盒子模型 二

    Sublime 快捷键:

    文件保存后,输入 html:xt + tab  ,补全html

    html:xt
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <title>Document</title>
    </head>
    <body>
        
    </body>
    </html>

    补全class

    div.nav + tab = 

    <div class="nav"><div>

    输入多行<a> 标签

    a[#]*3 + tab

    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>

    案例:

    模仿新浪首页

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <title>Document</title>
        <style type="text/css">
            .nav{
                height: 40px;
                background: #eee;
                border-top: 3px solid orange;
                border-bottom: 1px solid #aaa;
            }
            .nav-con{
                 1000px;
                height: 40px;
                margin: 0  auto; /*盒子居中对齐*/
                /*line-height: 40px;*/
            }
            a{
                font:12px/40px 微软雅黑;/* 文字大小 行高 */
                color: #333;
                display: inline-block;
                height: 40px;
                text-decoration: none;
            }
            a:hover{
                background: #999;
            }
        </style>
    
    </head>
    
    <body>
        <div class="nav">
            <div class="nav-con">
                <a href="#">设为首页</a>
                <a href="#">手机新浪网</a>
                <a href="#">移动客户端</a>
            </div>
        </div>
    </body>
    </html>

    垂直方向外边距合并 

       垂直方向的两个盒子,如果都设置了垂直方向的外边距,取设置的较大的值。

    外边距塌陷

        嵌套的盒子,直接给子盒子设置垂直方向外边距的时候,会发生外边距塌陷。

        解决方法:

        1.给父盒子设置边框;

        2.给父盒子设置 overflow:hidden      bfc 格式化上下文。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <title>Document</title>
        <style type="text/css">
            .father{
                 500px;
                height: 400px;
                background: #232323;
                border: 1px solid #232323;
            }
            .son{
                 200px;
                height: 200px;
                background: #eee;
                margin-top: 50px;
            }
        </style>
    </head>
    <body>
        <div class="father">
            <div class="son">
            </div>
        </div>
    </body>
    </html>

     

  • 相关阅读:
    cookie、session和会话保持
    常见的一些专业术语的概念
    JS中的执行机制(setTimeout、setInterval、promise、宏任务、微任务)
    加密和解密
    ASCII 、UTF-8、Unicode编码
    localhost、127.0.0.1、本机ip、0.0.0.0 的区别
    使用Bootstrap框架的HTML5页面模板
    js判断是否在微信浏览器中打开
    js获取url的参数
    js动态生成下拉列表
  • 原文地址:https://www.cnblogs.com/taiguyiba/p/8493430.html
Copyright © 2011-2022 走看看