+ -
当前位置:首页 → 问答吧 → css如何设置input在IE6,ie7下背景固定

css如何设置input在IE6,ie7下背景固定

时间:2010-08-27

来源:互联网

在IE7及以下版本,无法使input背景图片固定。设置background-attachment:fiexed;只会让背景变的更乱。
当输入框的字数长度超过输入框的宽度,如何写CSS才能不让背景图片左移。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <style type="text/css"> .inputbox{ background:url(http://bbs.blueidea.com/attachment.php?aid=150973&k=1903894b88fda63f511b2839c00c8390&t=1282900811&noupdate=yes) no-repeat top left; width:236px; height:15px; border:none;padding:4px 8px;_width:252px; _height:23px; _padding:4px 8px;color:#999999; overflow:hidden} .inputbox:hover{background-position:left bottom;} </style> </head> <body> <input type="text" class="inputbox" name="keywords" id="keywords" value="输入关键字..." size="10"> <input type="text" name="keywords" id="keywords" value="输入关键字..."> </body> </html>
 提示:您可以先修改部分代码再运行
[ 本帖最后由 TomiEric 于 2010-8-27 17:28 编辑 ]

附件

input.gif (1.94 KB)

2010-8-27 17:20

22222222.jpg (6.96 KB)

2010-8-27 17:20

作者: TomiEric   发布时间: 2010-08-27

在IE6下都乱了啊

作者: hcp8706   发布时间: 2010-08-27

给文本输入框外加一层标签,然后把背景给外层标签。

作者: birdstudio   发布时间: 2010-08-30

我是把两头圆角部分做成图片,中间做循环背景

作者: lcgtpr   发布时间: 2010-08-31

引用:
原帖由 birdstudio 于 2010-8-30 13:20 发表
给文本输入框外加一层标签,然后把背景给外层标签。
嗯,之前也这样想。是被一次ie低版本浏览器中input背景background:transparent不能透明才没有尝试。
外加span,暂测试ie6及以上通过

作者: TomiEric   发布时间: 2010-09-02

外层有DIV,有时候给txt写width:100%,会不起作用,txt只显示一半,不知道怎么回事

作者: uuucat   发布时间: 2010-09-03