2013-10-21 33 views
1

此代碼適用於ios6(文本在選擇框中居中對齊)。但在ios7中,它是對齊的?在ios7上選擇中心文本

select { 
    text-align: -webkit-center; 
} 

有沒有人知道如何解決這個問題,以在ios7選擇中心文本?

感謝

+0

您是否嘗試過'text-align:center'而沒有'-webkit'供應商。似乎不支持。 –

+0

是的,不適用於ios7和ios6。 text-align:-webkit-center;雖然工作在6 – user2076941

回答

0

您可以使用angularjs這一招,或使用JS來對股利文本地圖選擇的值,這個解決方案是完整的CSS兼容的角度,但需要選擇與格之間的映射:

var myApp = angular.module('myApp', []); 
 

 
myApp.controller('selectCtrl', ['$scope', 
 
    function($scope) { 
 
    $scope.value = ''; 
 
}]);
.ghostSelect { 
 
    opacity: 0.1; 
 
    /* Should be 0 to avoid the select visibility but not visibility:hidden*/ 
 
    display: block; 
 
    width: 200px; 
 
    position: absolute; 
 
} 
 
.select { 
 
    border: 1px solid black; 
 
    height: 20px; 
 
    width: 200px; 
 
    text-align: center; 
 
    border-radius: 5px; 
 
    display: block; 
 
}
<!doctype html> 
 
<html lang="en"> 
 

 
<head> 
 
    <meta charset="UTF-8"> 
 
    <title>Example - example-guide-concepts-1-production</title> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
</head> 
 
<body ng-app="myApp"> 
 
    <div ng-app ng-controller="selectCtrl"> 
 
    <div class=select> 
 
     <select ng-model="value" class="ghostSelect"> 
 
     <option value="Option 1">Option 1</option> 
 
     <option value="Option 2">Option 2</option> 
 
     <option value="Option 3">Option 3</option> 
 
     </select> 
 
     <div>{{value}} 
 
     </div> 
 
    </div> 
 
    </div> 
 
</body>

希望爲我花了一天的時間找到PhoneGap的這一解決方案,這可能是有用的人。