将图像放在输入框内的右侧

时间:2014-03-07 15:16:24

标签: html css html5 css3

如何让我的双向下箭头图像位于输入框内的右侧,它也必须是可点击的。

这是我的图片:enter image description here

以下是所需结果的图片:enter image description here

HTML代码:

<!DOCTYPE html>    
<html>
  <head></head>
  <body>
    <input type="text" style="border: 1px solid #000;">
    <img src="double_arrow.png" style="width: 19px; height: 18px;">
  </body>
</html>

1 个答案:

答案 0 :(得分:3)

将它们都包裹在相对定位的外部容器中。然后将图像设置为绝对位置并锚定到右侧

<div class="combo">
  <input type="text">
  <img class="trigger">
</div>

.combo { position: relative; }
.combo .trigger { position: absolute; right: 0; top: 1px }

这样的事情应该起作用

相关问题