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

html-css0149

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、查看效果。

1、使用CSS来覆盖图片:

a) 将图片放置在一个容器中,然后设置容器的背景颜色;

b) 使用CSS的position属性将图片定位在容器的最上层,并设置其透明度;

c) 将容器的宽度与高度设置为图片的宽度与高度,以覆盖整个图片;

2、使用Canvas来覆盖图片:

a) 将图片放置在一个Canvas中;

b) 使用Canvas的fillRect()方法添加一个覆盖图片的矩形,并设置其颜色。

1、首先我们创建一个简单的项目,如图所示包括html,css和img三个。

2、这里是html文件,引入css和html代码文件,如图所示。

3、这里是css文件代码,上面是div和图片显示的效果代码,后面是动画效果。

4、这里是事件,这里定义了四个时间段的状态,兼容了ie的。

5、如图所示这里是效果图,会根据时间轮播显示下一张图片 了。