2015-11-13 34 views
0

由於WebKit的樣式,我努力讓複選框在iOS上正確居中。我正在使用bootstrap來創建響應式設計。使用引導程序的iOS複選框不會中心

這是內部監督辦公室毀了我的代碼的結果:

iOS styling of bootstrap checkbox

我使用下面的代碼:

<div class="form-group"> 
    <label class="control-label col-xs-5 col-sm-2" for="formatA">Format:</label> 
    <div class="col-xs-3 col-sm-2"> 
     <input type="checkbox" class="form-control" id="formatA" name="formatA"> 
    </div> 
    <div class="col-xs-4 col-sm-4"> 
     <input type="date" class="form-control" id="formatD" name="formatD" placeholder="Enter date of format approval"> 
    </div> 
</div> 
+0

如果垂直居中問題是iOS獨佔,請在複選框上嘗試-webkit-appearance:none。 – Thomas

+0

這是問題的橫向居中,抱歉我應該更清楚,我會更新我的問題。我試過你的解決方案,它只是使複選框的行爲非常奇怪。謝謝。 –

回答

0

好了,所以我做了一個plunker解決方案。我再次查看引導程序網格語法,發現可能存在您如何佈置網格的一些問題。我再次開始啓動,這是我想出了

http://plnkr.co/edit/x3vDfl15LA2yxxDOeUQT

<div class="container-fluid"> 
     <div class="row"> 
     <div class="col-xs-4"> 
      <label class="control-label" for="formatA">Format:</label> 
     </div> 
     <div class="col-xs-4"> 
      <input type="checkbox" class="" id="formatA" name="formatA" /> 
     </div> 
     <div class="col-xs-4"> 
      <input type="date" class="form-control" id="formatD" name="formatD" placeholder="Enter date of format approval" /> 
     </div> 
     </div> 
    </div> 

CSS

html{ 
     font-size: 16px; 
    } 
    input[type="checkbox"]{ 
     display:block; 
     margin:0 auto; 
     padding: 20px; 
    } 
    input[type="date"]{ 
     width:100%; 
    } 

這讓我這個結果在我的iPhone 6+ iphone6

+0

不幸的是,他們似乎沒有效果,他們仍然保持對齊的左邊 –

+0

哦,嘗試添加一個寬度複選框,像50像素或什麼我會改變我的答案,以反映 – BrianBest

+0

仍然沒有效果,只是推動頁面變寬,但對複選框本身沒有影響。這是因爲蘋果嚴格的webkit風格。 –

相關問題