How do I add a “search” button in a text input field?

前端 未结 7 1452
梦毁少年i
梦毁少年i 2020-11-27 18:49

How do I create a similar “search” element to the one in this site?

\"enter

If

7条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 19:31

    Put the image into the span, for example using background-image, then give it a relative position and move it to the left so it overlaps the right end of the search box, for example:

    #g-search-button {
      display: inline-block;
      width: 16px;
      height: 16px;
      position: relative;
      left: -22px;
      top: 3px;
    
      background-color: black;  /* Replace with your own image */
    }
    

    Working example on JSBin

提交回复
热议问题