jquery - iphone 和三星 galaxy 字体大小不同

标签 jquery html css angularjs cordova

我曾尝试使用 PhoneGap 构建主视图。 主视图有一些包含图像和文本的按钮。 每个按钮都有以下语句:

<div  ng-repeat="module in Modules" ng-click="setPage(module)" class="button" style="background-color: #ffffff;
                                                                    height: 11%;
                                                                    width: 60%;
                                                                    margin-bottom: 3px;
                                                                    margin-top: 1.5%;
                                                                    opacity: 0.8;
                                                                    padding-right: 0px;
                                                                    padding-left: 0px;
                                                                    text-align: center;
                                                                    font-size: 1em;">
            <img class="imgMain"  ng-src={{module.IconUrl}}>
            <span class="spanMain">{{module.Name}}</span>
</div>

CSS:

.spanMain{
font-size: 1em;
position: absolute;
bottom: 0;
right: 0;left: 0;"}

.imgMain{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 25%;
margin: auto;
max-width: 50%;
max-height: 50%;}

在 iPhone 上它看起来很棒,但是在 galaxy 中,<#span tag#> 中的模块名称(即文本)以较小的字体显示文本。 如果我将字体大小更改为更大的大小,在 iPhone 上它会显示得很大,真的不成比例,但在 galaxy 上它没问题。我该如何解决?

非常感谢,

最佳答案

不知道这个解决方案是否有效,但我猜你可以这样做:

编辑:用您的值名称制作我的解决方案

JavaScript:

$scope.device = "";
if ((navigator.userAgent.match(/iPhone/)) || (navigator.userAgent.match(/iPod/))) {
 $scope.device = "iphone";
}else if (navigator.userAgent.match(/Android/)) {
 $scope.device = "android"
}

HTML:

<span class="spanMain" title="{{device}}">{{module.Name}}</span>

CSS:

.spanMain{
 font-size: 1em;
 position: absolute;
 bottom: 0;
 right: 0;
 left: 0;
}

.spanMain[title=iphone]{
 font-size: 1em;
}

.spanMain[title=android]{
 font-size: 2em;
}

关于jquery - iphone 和三星 galaxy 字体大小不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21114785/

相关文章:

html - 我可以在线定义翻转 CSS 样式吗?

javascript - 如何使用 Promise 链接两个 Ajax 请求

javascript - jQuery:在所有事件发生变化后只运行一次回调函数

javascript - 检查元素是否显示 : block, 不工作

html - 为什么丢失的图像显示损坏的图像而不是 Chrome 中 alt 标签的文本?

html - 如何覆盖 Bootstrap 样式

jquery - 当悬停一个 div 时,其余部分会发生变化

javascript - 带有自定义函数调用的 HTML 表单

html - 标题背景未加载

javascript - 如何更改 IE 中的 cssText?