English 中文(简体)
不显示以上文本框的 div
原标题:div not showing above text box
  • 时间:2012-05-23 09:00:01
  •  标签:
  • html
  • css

我想在文本输入框的起始部分显示搜索图标 。

目前我的代码是这样的:

<div id="search-icon"></div>
<input type="text" name="search" id="search"/>

和我的CSS:

#search-icon {
    display:inline-block;
    background-color:#455a21;
    height:60px;
    width:60px;
    border:thin solid black;
    border-radius:30px;
    z-index:100;
}

input#search {
    position:relative;
    top:-25px;
    left:-30px;
    padding:10px;
    padding-left:35px;
    border-radius:20px;
    border:thin solid #6d6e71;
    z-index:1;
}

它向右显示 div 位置, 但是在实际文本框下方。 当我将搜索图标位置更改为绝对时, 它会破坏我的定位 。

我该怎么打?

最佳回答

你可以用两者的相对位置来解决它。但只需改变它们的z-index。

#search-icon {

background-color:#455a21;
height:60px;
width:60px;
border:thin solid black;
border-radius:30px;
z-index:100;
position: absolute;
z-index: 2;
}

input#search {
position:absolute;
top:15px;
left:30px;
padding:10px;
padding-left:35px;
border-radius:20px;
border:thin solid #6d6e71;
z-index:1;}​

这是您正在寻找的 < a href=> "http://jsfiddle.net/TyVBp/6" rel="no follow" >这里

问题回答

你是说在#searing的输入上 要有搜索象子吗?

例如:http://jsfidle.net/52YfE/ ?

我不知道你到底想要什么,但看看这个 "http://jsfidle.net/V8AZE/"rel="nolfollow">http://jsfidle.net/V8AZE/





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签