0

私がやろうとしていること: テキストボックスの右側に検索アイコンを追加します

ここに画像の説明を入力

[css] で使用しているコードは次のとおりです。

.tb4 {
background: #3f4c6b; /* Old browsers */
background: -moz-linear-gradient(top,  #3f4c6b 0%, #3f4c6b 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#3f4c6b), color-stop(100%,#3f4c6b)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #3f4c6b 0%,#3f4c6b 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #3f4c6b 0%,#3f4c6b 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #3f4c6b 0%,#3f4c6b 100%); /* IE10+ */
background: linear-gradient(to bottom,  #3f4c6b 0%,#3f4c6b 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f4c6b', endColorstr='#3f4c6b',GradientType=0 ); /* IE6-9 */
 background: url(web.png) top right no-repeat;
 padding: 4px 4px 4px 22px;
 height: 18px;
 border: 1px solid #494949;
}

私が得る結果は次のとおりです。

ここに画像の説明を入力

  • メインフォルダーに web.png があります。*
4

3 に答える 3

0

グラデーションと背景画像が競合します。試す:

.tb4 {
  /* as above but without the background line for web.png */
  position: relative; /* and add this line */
}
.tb4:after { /* and this rule */
  content: "";
  display: block;
  width: 20px; /* change dimensions as needed to match image */
  height: 20px;
  background: url(web.png) top right no-repeat;
  position: absolute;
  top: 0;
  right: 0;
}
于 2013-06-16T01:59:55.530 に答える
0
background: url(web.png) top right no-repeat;

This is over-ruling the other background settings. You've tried background-image but I suspect that this conflicts with the gradient settings, which are effectively using an image-property of the background.

Added: This SO topic indicates that it is possible to combine gradients with an image.

I would add the button immediately after the search box, and use positioning, perhaps a negative left-margin, to bring it back over the textbox. If the textbox is an input element then I would probably use the image as a background to a label, and bring this label back across to the left, perhaps with a z-index to place it above the textbox.

于 2013-06-16T01:56:25.733 に答える