gpt4 book ai didi

html - 使用 html5 和 css3 的带有搜索图像的文本框

转载 作者:太空宇宙 更新时间:2023-11-04 15:42:12 24 4
gpt4 key购买 nike

我正在使用 html5 和 css3 制作第一个网站。要显示带有我找到的搜索玻璃图像的文本框 this帮助,效果很好,例如: enter image description here

代码如下:

HTML

<form id="header-search">
<input type="text" class="searchbox" /><input type="submit" class="button" value="" />

CSS

#header-search{overflow:auto;}

#header-search input.searchbox {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
border:1px solid #8e8e8e;
background-color:#f5f5f5;
height:16px;
padding:4px;
padding-right:28px;
color:#4a4a4a;
float:left;
}

#header-search input.button{
border:0;
padding:0;
margin:0 0 0 -24px;
width:24px;
height:24px;
background:transparent url('your-search-icon-path-here') center center no-repeat;
float:left;
}

我需要在文本框的右侧显示搜索图像 我试图理解 CSS 但无法理解。

能否请您指导我什么是文本框中的分组图像。 CSS 代码中没有 display 属性,如何控制它的显示和定位?

如何从文本框的左侧更改其显示?

谢谢

最佳答案

在给定的示例中,padding make 会混淆计算搜索框的实际宽度(不会太困惑,但有一点)。

所以首先看一下我通过修改你的例子制作的这个例子:Example

这里实际发生的事情是按钮被安排在输入框旁边。但是我们通过给定 -24 的边距(这是图像的宽度)来强制它在左侧移动。所以通过减少 24px 的左边距使它看起来像在文本框中。现在如果我们想将图像左对齐,那么我们可以将左边距缩小到文本框的宽度,使它看起来像在左边。

margin:0 0 0 -200px;

这里200px是文本框的宽度。

Example for Left Image

关于html - 使用 html5 和 css3 的带有搜索图像的文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12018508/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com