• 两个div不同高度并排显示


    在HTML中让两个div并排显示,通常情况下有三种实现方式,包括:

    (1)设置为行内样式,display:inline-block

    (2)设置float浮动

    (3)设置position定位属性为absolute

    以下为三种方式的具体实现代码:

    1、设置每个div的展现属性为行内样式,示例代码为:

    <div class="app">

    <div style="display:inline-block;background:#f00;">div1</div>

    <div style="display:inline-block;background:#0f0;margin-left:10px;">div2</div>

    </div>

    2、设置float浮动,示例代码为:

    <div class="app">

    <div style="float:left;background:#f00;">div1</div>

    <div style="float:left;background:#0f0;margin-left:10px;">div2</div>

    </div>

    3、设置position定位属性为absolute, 示例代码为:

    <div class="app">

    <div style="position: absolute;100px;background:#f00;">div1</div>

    <div style="position: absolute;left:100px;background:#0f0;margin-left:10px;">div2</div>

    </div>

    扩展资料:

    css清除浮动方法

    (1)添加新的元素 、应用 clear:both

    .clear {

    clear: both; 

    height: 0;

    height: 0;

    overflow: hidden;
    }

    (2)父级div定义 overflow: auto

    .over-flow {

    overflow: auto;

    zoom: 1; //处理兼容性问题

    }

    (3)伪类  :after 方法  outer是父div的样式

    .outer { zoom:1; }    /*==for IE6/7 Maxthon2==*/

    .outer :after {

    clear:both;

    content:'.';

    display:block;

    0;

    height: 0;

    visibility:hidden; 

    }

    链接:https://zhidao.baidu.com/question/135016260138604645.html

  • 相关阅读:
    堆和栈的区别
    VS-Visual Studio-IIS Express 支持局域网访问
    理解Session的几种模式
    HTTP Keep-Alive模式
    C#[Serializable]在C#中的作用-NET 中的对象序列化
    深入理解asp.net SessionState
    .NET中JSON的序列化和反序列化
    数据库相关命名规范
    PHPStorm+PHP5.6+WIN7+IIS7
    深入理解C# 静态类与非静态类、静态成员的区别
  • 原文地址:https://www.cnblogs.com/wanlibingfeng/p/10676736.html
Copyright © 2020-2023  润新知