跨平台设置输入文本框大小的更好方法?

时间:2011-11-24 01:46:45

标签: android html css ios blackberry

更新低于代码块。

原始问题: 我有一个输入字段,它远远超出页面的其余部分,但正如问题所暗示的那样,在iOS3 / 4/5中看起来很好。

我想知道是否有人遇到过这个问题。我的搜索按钮,在iOS中位于搜索文本框的右侧,实际上包含在其他平台上的下一个“行”中。

代码如下:

HTML

<form action="/jsp/mobile_files/results.jsp" method="get" autocorrect="off"     autocapitalize="off">
<h1><input class="keyword_search" type="text" name="keywords" maxlength="50" size="36" value="" /><input type="submit" class="keyword_submit" value="Go" /></h1>
</form>

两个相关的CSS类是:

 /* input[type="submit"] */
 .keyword_submit
 {
   background: #666666;  /* grey */
   color: #FFFFFF;  /* white */
   font-weight: bold;
   font-size: 60%;
   line-height: 1.45em; /* 1.45 with 60% font-size */

   margin-left: -4px; /* to do - needs to be -12 for desktop */
   padding-bottom: 1px;


   -moz-border-radius: 10px;       /* for mozilla firefox */

   /* NOTE: CSS3 rounded corners not work on iPhone 3G with iOS 3.x */
   border-radius: 10px;

   /* webkit rounded corners work on iPhone 3G with iOS 3.x */
   -webkit-border-radius: 10px;


   -moz-border-radius-topleft: 0px;      /* for mozilla firefox */
   -moz-border-radius-bottomleft: 0px;

   /* NOTE: CSS3 rounded corners not work on iPhone 3G with iOS 3.x */
   border-top-left-radius: 0px;
   border-bottom-left-radius: 0px;

   /* but this does work on iPhone 3G with iOS 3.x */
   -webkit-border-top-left-radius: 0px;
   -webkit-border-bottom-left-radius: 0px;

   /* to do - possible without this??  We lose the gradient! */
   -webkit-appearance: none;
 }

/* input[type="text"] */
  .keyword_search {
    background: #F1F1F1;  /* faded white */
    color: #333333;  /* dark */
    font-weight: bold;

    /* to do - looks better on iOS with larger font */
    /*
    font-size: 80%;
    */

    -moz-border-radius: 10px;       /* for mozilla firefox */

    /* NOTE: CSS3 rounded corners not work on iPhone 3G with iOS 3.x */
    border-radius: 10px;

    /* webkit rounded corners work on iPhone 3G with iOS 3.x */
    -webkit-border-radius: 10px;

    margin-left: 0.75em; /* moves entry field to the right */
    padding-left: 0.6em; /* moves text start cursor in the entry field to the right */

    /* for mozilla firefox */
    -moz-border-radius-topright: 0px;      
    -moz-border-radius-bottomright: 0px;

    /* NOTE: CSS3 rounded corners not work on iPhone 3G with iOS 3.x */
    border-top-right-radius: 0px;
    border-bottom-right-radius: 0px;

    /* but this does work on iPhone 3G with iOS 3.x */
    -webkit-border-top-right-radius: 0px;
    -webkit-border-bottom-right-radius: 0px;
  }

更新了问题 屏幕截图可以在http://i.stack.imgur.com/5f7C8.jpg看到我会在这里发布,但我需要超过10个声望才能发布图片。 您可以在Android图像中看到如果输入的大小设置为对任何平台而言太大,会发生什么。为了使其适合BlackBerry,您可以看到它在iOS中呈现的大小。所有三个img的大小都设置为相同的值(=“10”)......你可以在不同的平台上看到结果。

<input class="keyword_search" type="number" name="job_order_id" maxlength="7" size="10" value="" />
<input type="submit" class="keyword_submit" value="Go" />

建议更好地控制尺寸?我可以使用%,em,px或某些跨平台更一致的单元吗? (在我把尺码整理好后,我会担心摆脱差距,按钮的大小和其他调整)

1 个答案:

答案 0 :(得分:0)

当回来尝试其他一些事情时,我注意到我错了。上述评论是使用size=#%进行的,但是当您使用width: #%;时,它会消除跨平台的广泛差异。