css3怎么在input搜索框里添加图片

css3怎么在input搜索框里添加图片,第1张

1、新建html文档。

2、书写hmtl代码

<div class="container">

<div id="search">

<label for="search">点击查看效果(<a href="#" target="_blank">11111111111</a>):</label>

<input type="text" name="q">

<input class="button" type="submit" value="Search">

</div>

</div>

3、书写css代码。

<style>

body { background-color: #f1f1f1margin: 0}

body,  input,  button { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif}

.container { margin: 30px auto 40px autowidth: 800pxtext-align: center}

a { color: #4183c4text-decoration: nonefont-weight: bold}

a:hover { text-decoration: underline}

h3 { color: #666}

ul { list-style: nonepadding: 25px 0}

li { display: inlinemargin: 10px 50px 10px 0px}

input[type=text],  input[type=password] { font-size: 13pxmin-height: 32pxmargin: 0

padding: 7px 8pxoutline: nonecolor: #333background-color: #fffbackground-repeat:

no-repeatbackground-position: right centerborder: 1px solid #cccborder-radius: 3px

box-shadow: inset 0 1px 2px rgba(0,0,0,0.075)-moz-box-sizing: border-boxbox-sizing:

border-boxtransition: all 0.15s ease-in-webkit-transition: all 0.15s ease-in 0vertical-align: middle}

button { position: relativedisplay: inline-blockmargin: 0padding: 8px 15pxfont-size:

13pxfont-weight: boldcolor: #333text-shadow: 0 1px 0 rgba(255,255,255,0.9)white

space: nowrapbackground-color: #eaeaeabackground-image: -moz-linear

gradient(#fafafa, #eaeaea)background-image: -webkit-linear-gradient(#fafafa, #eaeaea)

background-image: linear-gradient(#fafafa, #eaeaea)background-repeat: repeat-x

border-radius: 3pxborder: 1px solid #dddborder-bottom-color: #c5c5c5box-shadow:

01px 3px rgba(0,0,0,.05)vertical-align: middlecursor: pointer-moz-box-sizing: border-box

box-sizing: border-box-webkit-touch-callout: none-webkit-user-select: none-khtml

user-select: none-moz-user-select: none-ms-user-select: noneuser-select: none

webkit-appearance: none}

.button:hover,  .button:active { background-position: 0 -15pxborder-color: #ccc #ccc

#b5b5b5}

.button:active { background-color: #dadadaborder-color: #b5b5b5background-image:

nonebox-shadow: inset 0 3px 5px rgba(0,0,0,.15)}

.button:focus,  input[type=text]:focus,  input[type=password]:focus { outline: noneborder

color: #51a7e8box-shadow: inset 0 1px 2px rgba(0,0,0,.075), 0 0 5px rgba(81,167,232,.5)}

label[for=search] { display: blocktext-align: left}

#search label { font-weight: 200padding: 5px 0}

#search input[type=text] { font-size: 18pxwidth: 705px}

#search .button { padding: 10pxwidth: 90px}

</style>

4、代码整体结构。

5、查看效果。

这要看你怎么写的了;如全局定位的body为根节点a为搜索框,b为下拉展示

a{

width:300px

height:50px

margin-top:100px

margin-left:100px

}

b{

width:100px

background:#fff(背景颜色控制,也可以为背景图片)

position:absolute

z-index:3(图层控制)

top:150px(top为搜索框距顶部(body的高度)高度+搜索框高度)

left:100px(left为搜索框距左边的距离)

}

不管怎么写就看你以哪个为根节点了

如果你是想要通过将图片放到搜索栏来搜索图片,那我告诉你这是不现实的,至少现在还没有这种基于图像元素的搜索算法。李开复到我们学校演讲的时候说过,他和微软公司打官司的时候微软将证据放在图片里,然后将这个图片混合到几百万张图片库中一起发给他,希望以此气他而且是他受打击,结果他和一些人耗费很大物力财力才找到那张图片打赢官司。他在事后说,他感觉谁要是能发明出这么一种通过图片元素搜索的方法,那这个人毫无疑问将取代比尔盖茨的位置,但是很可惜,至今没有这么一个人出现,也就是说,这种方法到现在还没有实现。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11893076.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-19
下一篇2023-05-19

发表评论

登录后才能评论

评论列表(0条)

    保存