CSS - Percentages or Pixels?

前端 未结 9 771
梦如初夏
梦如初夏 2020-12-04 21:54

I have been using CSS for many years now, and I have always been a \'percentage\' kind of guy, as in I always define heights and widths using percentages as opposed to pixel

9条回答
  •  孤城傲影
    2020-12-04 22:48

    in inner style top property is in % so it will count as 200px*0.3=60px

    #outer{
      border-style: dotted;
      position: relative; 
      height: 200px;
    }
    #inner{
     border-style: double;
      position: absolute;
      top: 30%; <<<<<<<<<<<<<<
    }
    outer
    inner

    Here top is 30px . so it will be as it is.

    #outer{
      border-style: dotted;
      position: relative; 
      height: 200px;
    }
    #inner{
     border-style: double;
      position: absolute;
      top: 30px; <<<<<<<<<<<<
    }
    outer
    inner

提交回复
热议问题