goTOP
January 4, 2018

手機版 nav line-height 與 padding 間的問題

| |
網頁語言 » CSS | 閱覽(1706) | Posted by apao at 12:33
當我製作手機版網頁時,習慣性的沿用PC版的CSS定義
發現一個跟 padding 完全無關的問題(BUG)

點擊在新視窗中瀏覽此圖片
HTML for mobile
<a href="index.php">首頁 home</a><a href="Category.php">商品清單 Category</a><span>某某商品名稱</span>

CSS for mobile
nav{
  width: 100%;
  background: url(../i/iconHomeGray-19.png) no-repeat left center;
  margin: 0 20px 0px 0;
  padding: 0 0 0 25px;
  color: rgba(0,0,0,1.00);
  font-size: 120%;
  line-height: 200%; /*記得不能加上行高*/
}
nav a{
  display: inline-block;
  background: rgba(101,109,168,0.70);
  margin: 0 5px 0 0;
  padding: 2px 4px; /*完全不為所動*/
  border-radius: 9px;
  color: rgba(255,255,255,0.90);
  line-height: 200%; /*設定這裡的行高也會有問題*/
}
nav span{
  display: inline-block;
}


點擊在新視窗中瀏覽此圖片
正常的 CSS for mobile
nav{
  width: 100%;
  background: url(../i/iconHomeGray-19.png) no-repeat left center;
  margin: 0 20px 0px 0;
  padding: 0 0 0 25px;
  color: rgba(0,0,0,1.00);
  font-size: 120%;
  /* line-height: 200%; 去除行高*/
}
nav a{
  display: inline-block;
  background: rgba(101,109,168,0.70);
  margin: 0 5px 0 0;
  padding: 2px 6px; /*改變這個部分*/
  border-radius: 9px;
  color: rgba(255,255,255,0.90);
  /* line-height: 200%; 去除行高*/
}
nav span{
  display: inline-block;
}
Facebook twitter LINEk
文章来自: 本站原創
0 Comment(s)
我要發表評論
暱稱
密碼 [ 訪客無需密碼 ]
電郵
網址
開啟HTML 開啟UBB 開啟表情 隱藏 記住我