CSS Tricks

Vertical Center

Set the same height and line-height

.element {
    height: $ELEMENT_HEIGHT;
    line-height: $ELEMENT_HEIGHT;
}

Distribute gap between grids

$HOW_MANY_GRID_EACH_ROW: 3
$GRID_WIDTH: 100% / 3;
$GAP_WIDTH: 16px;
$DISTRIBUTED_GAP: $GAP_WIDTH * ($HOW_MANY_GRID_EACH_ROW - 1) / $GRID_WIDTH;
.grid {
   width: calc($GRID_WIDTH-$DISTRIBUTED_GAP);
   float: left;
   &:nth-child(3n+2), &:nth-child(3n+3){
      margin-left: $GAP_WIDTH;
   }
}

Padding Content from Header

Input with search icon

Line-height border-box problem

https://www.w3ctech.com/topic/127

  • LineHeight 不計算在box 的範圍之內,所以line-height撐大,chrome deve tool 看不到整個元素的範圍

Last updated

Was this helpful?