CSS 中类似于 Android ICS 的输入字段

标签 android html css

<分区>

我想创建一个像 Android Ice Cream Sandwich 那样的输入字段,仅使用 HTML/CSS 且不使用图像。
我坚持制作这些小边框(下图),如果有人能提供帮助,那就太好了。

Android inpu field

最佳答案

编辑

我想包括 owencm 对遇到这个问题的人的评论,因为我觉得它很优雅:

CSS

input.holo[type='text'] {
    /* You can set width to whatever you like */
    width: 200px;
    font-family: "Roboto", "Droid Sans", sans-serif;
    font-size: 16px;
    margin: 0;
    padding: 8px 8px 6px 8px;
    position: relative;
    display: block;
    outline: none;
    border: none;
    background: bottom left linear-gradient(#a9a9a9, #a9a9a9) no-repeat, bottom center linear-gradient(#a9a9a9, #a9a9a9) repeat-x, bottom right linear-gradient(#a9a9a9, #a9a9a9) no-repeat;
    background-size: 1px 6px, 1px 1px, 1px 6px;
}
input.holo[type='text']:hover, input.holo[type='text']:focus {
    background: bottom left linear-gradient(#0099cc, #0099cc) no-repeat, bottom center linear-gradient(#0099cc, #0099cc) repeat-x, bottom right linear-gradient(#0099cc, #0099cc) no-repeat;
    background-size: 1px 6px, 1px 1px, 1px 6px; 
} 

HTML

<input type='text' class='holo'/>

JSFiddle http://jsfiddle.net/QKm37/

原始解决方案

<span style="
  border-bottom: solid 1px cyan;
  border-left: solid 1px cyan;
  margin: 20px;
  border-right: solid 1px cyan;
  overflow: visible;
  max-height: 0.2em;
  display: inline-block;
  padding: 2px;
">
<input type="text" style="
  outline: none;
  border: none;
  background: transparent;
  display: inline-block;
  position: relative;
  bottom: 0.8em;
">
</span>

关于CSS 中类似于 Android ICS 的输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11816166/

相关文章:

css - 如何将图像颜色置于文本下方?

html - 如何在我的 thead 部分底部制作边框?

java - 如何在 Android 应用程序中禁用 Android 键盘

安卓12 : BLE Scan does not find any devices

jquery - 使用 jQuery 单击元素时如何使 div 出现

html - 当 View 小于内容时滚动静态内容

css - 根据高度设置宽度

android - 在刷新时禁用 ListView 中的滚动

android - 如何知道一天在android中何时开始?

javascript - 更改 Service.js 中的 var 值