html - jQuery Mobile - 如何在搜索栏上获取搜索图标?

标签 html css jquery-mobile

我正在尝试实现一个搜索栏
但是我无法在搜索栏上显示搜索图标。
这是code (jsfiddle) 。 我发现默认样式会覆盖我的自定义样式。

HTML

<div id="search_controls">
    <input type="text" class="search-box" placeholder="e.g. restaurant name, cuisine" />
</div>

input.ui-input-text, textarea.ui-input-text {
background-image: none;
padding: .4em;
margin: .5em 0;
line-height: 1.4;
font-size: 16px;
display: block;
width: 100%;
outline: 0;
}

自定义样式

#search_controls + input.ui-input-text{
    background: url('../img/search_icon.png') 98% center no-repeat!important;
    height: 26px;
    padding: .4em;
    margin: .5em;
    font-size: 15px;
    display: block;
    width: 99%!important;
    outline: 0;
}

如何解决这个问题?

最佳答案

也许我现在知道你的意思了...... 只需删除自定义 CSS 中的 + 符号即可正常工作;-)...

enter image description here

示例代码:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Test</title>
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
  <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

  <style>
  #search_controls input.ui-input-text{
    background: url('taifun.png') 98% center no-repeat!important;
    height: 26px;
    padding: .4em;
    margin: .5em;
    font-size: 15px;
    display: block;
    width: 99%!important;
    outline: 0;
  }
  </style>
</head>

<body>
  <div data-role="page">
    <div id="search_controls">
      <input type="text" class="search-box" placeholder="e.g. restaurant name, cuisine" />
    </div>
  </div><!-- /page -->

</body>
</html>

关于html - jQuery Mobile - 如何在搜索栏上获取搜索图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13309955/

相关文章:

html - 当右侧和左侧不同时,如何重复标题图像的背景?

jquery - 更改可折叠元素的默认高度

html - 我无法让我的插件使用所有树状网格列

javascript - 用按钮 (Drupal) 替换页面中的 CSS(或页面元素)

html - 如何在 HTML 中打断长字符串?

javascript - 错误消息 无法在 'appendChild' : parameter 1 is not of type 'Node' 上执行 'Node'

javascript - Jquery远程补全,li的不可选

python - BS4 中出现奇怪的错误。 find_all() 返回 None

html - 我的 :hover selector is interrupted by text, 我该如何解决这个问题?

css - Bootstrap 3 - 屏幕分辨率为 480 像素或更小的不同网格