我在将我的应用程序转移到 phonegap 时遇到问题。当我在浏览器中查看该网站时,它看起来很正常,按钮与文本对齐(即使我将其调整为我正在使用的平板电脑的大小),但是当我在 phonegap 上尝试它时,它搞砸了。
它的样子(stackoverflow 不允许我上传图片,我的代表不是 10) http://postimg.org/image/k49v615zz/
它应该是什么样子
http://postimg.org/image/3t6g1a01p/
两个截图都是在浏览器里截的,但是第一个有
display: inline-flex !important;
未勾选,如您在 prntscr 上所见。任何人都有类似的问题,知道如何解决这个问题吗?
index.js 部分附加有问题的按钮
if(value.countable==true){
$detailList.append("
<div id='countable'>
<span>"+value.detailName+"</span>
<div data-role='controlgroup' data-type='horizontal' data-mini='true'>
<button class='button detailRow qtyminus' id='minus' data-inline='true'>-</button>
<input type='number' class='qty' min='0' inputmode='numeric' pattern='[0-9]*' name=detail."+value.detailId+" id="+value.detailId+" value="+ ((value.quantity == null)? + " 0": value.quantity) +" />
<button class='button detailRow qtyplus' id='plus' data-inline='true'>+</button>
</div>").trigger("create");
}
CSS
#countable {
width:100%;
}
#countable span {
display: inline-block;
width: 19em;
}
#countable div {
display:inline-block;
}
.qty {
position:relative;
float:right;
width: 9em;
height: 3em;
text-align: center;
}
input.qtyplus {
position:relative;
float:right;
width:2em;
height:2em;
}
input.qtyminus {
position:relative;
float:right;
width:2em;
height:2em;
}
.workerRow, .categoryRow, .taskRow {
text-align: left;
}
最佳答案
在元素中使用 %。
CSS
#countable span {
display: inline-block;
width: 60%;
}
.qty {
position:relative;
float:right;
width: 30%;
height: 3em;
text-align: center;
}
input.qtyplus {
position:relative;
float:right;
width:5%;
height:2em;
}
input.qtyminus {
position:relative;
float:right;
width:5%;
height:2em;
}
总元素空间宽度的 100%
但是尝试在你的元素中使用它,我将它用于我所有的元素,简单高效
CSS
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
outline: none;
}
.row:after {
content: '';
display: block;
clear: both;
}
.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
float: left;
position: relative;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
}
.col-md-1 {
width: 8.33333333%;
}
.col-md-2 {
width: 16.66666666666667%;
}
.col-md-3 {
width: 25%;
}
.col-md-4 {
width: 33.33333333333333%;
}
.col-md-5 {
width: 41.66666666666667%;
}
.col-md-6 {
width: 50%;
}
.col-md-7 {
width: 58.33333333333333%;
}
.col-md-8 {
width: 66.66666666666667%;
}
.col-md-9 {
width: 75%;
}
.col-md-10 {
width: 83.33333333333333%;
}
.col-md-11 {
width: 91.66666666666667%;
}
.col-md-12 {
width: 100%;
}
如何使用,很简单。最大列数为 12。
例如
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
</div>
3 列大小为 4 * 3 = 12
针对你的问题使用这个
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-1"></div>
<div class="col-md-4"></div>
<div class="col-md-1"></div>
</div>
网格系统很完美,用这个! (小演示 http://jsfiddle.net/dieegov/Bk2gB/1/ )
关于javascript - Phonegap/Cordova CSS 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23565102/