zoukankan      html  css  js  c++  java
  • 布局方式-inline-block布局

    .像文本一样排block元素
    .没有清除浮动等问题
    .需要处理间隙
     
     
    一种方式
    <style>
      .container{
        width: 800px;
        height: 200px;
        font-size: 0;
        /**
        * 使用inline-block,就相当于是文本,文字和文字之间肯定是有间隙的
        * 不可能连在一起,不管是什么字体,所以这里要将文本设置为0
        */
      }
      .left{
        font-size: 14px;
        background: red;
        display: inline-block;
        width: 200px;
        height: 200px;
      }
      .right{
        font-size: 14px;
        background: blue;
        display: inline-block;
        width: 600px;
        height: 200px;
      }
    </style>
    <body>
      <div class="container">
        <div class="left"></div>
        <div class="right"></div>
      </div>
    </body>




    另一种处理方式
    观察间隙的来源,他其实来自于html标记语言的空白

    如图,是这个间隙,一种写成这样

    <div class="container">
      <div class="left"></div><div class="right"></div>
    </div>

    另外一种写成这样

    <div class="container">
      <div class="left"></div><!--
      --><div class="right"></div>
    </div>

    把标记语言的空白注释掉也是可以掉

    但是因为这两种方式写起来都比较麻烦,所以一般还是使用字体的方式
    * 缺陷:自适应的布局比较麻烦
  • 相关阅读:
    hdu4998 旋转坐标系
    hdu4998 旋转坐标系
    hdu5012 水搜索
    hdu5012 水搜索
    hdu5007 小水题
    ZOJ 3645 BiliBili 高斯消元 难度:1
    ZOJ 3654 Letty's Math Class 模拟 难度:0
    ZOJ 3647 Gao the Grid dp,思路,格中取同一行的三点,经典 难度:3
    ZOJ 3646 Matrix Transformer 二分匹配,思路,经典 难度:2
    ZOJ 3644 Kitty's Game dfs,记忆化搜索,map映射 难度:2
  • 原文地址:https://www.cnblogs.com/wzndkj/p/10362666.html
Copyright © 2011-2022 走看看