Text indent is not working in ie7

2019-03-09 00:15发布

I am working on a website and on the top navigation bar there is a search box, I applied the following css on the search submit button

#submit {
   background: url("img/new-search-icon.png") no-repeat scroll -1px 0 #FFFFFF;
   border:0 none;
   cursor:pointer;
   display:block;
   height:21px;
   padding:0;
   position:absolute;
   right:0;
   text-indent:-9999px;
   top:0;
   width:20px;
   z-index:2;
}

My Problem is in IE7 the text indent is not working please help me if you want to see the demo you can view it by clicking here Click here. Please help me.

14条回答
Deceive 欺骗
2楼-- · 2019-03-09 01:02

Don't use text-indent. Try this one instead:

display: block;
height: 0;
padding-top: 20px; //The height of your button
overflow: hidden;
background: url(image.png) no-repeat; // Image replacement

Works in all browsers including IE6.

查看更多
倾城 Initia
3楼-- · 2019-03-09 01:05

Add this CSS to make IE7 behave:

text-transform: capitalize;

Crazy but true.

查看更多
劳资没心,怎么记你
4楼-- · 2019-03-09 01:05

.submit {
    line-height: 0px;
    font-size: 0px;
    /* restante do teu código */
    }

este é um exemplo simse

查看更多
我只想做你的唯一
5楼-- · 2019-03-09 01:05

The solution that I found to my text-indent woes in IE7, and something that I feel should be added to this thread is the following:

Doesn't work:

text-indent: -900009px;

Does work:

text-indent: -9999px;

I didn't know there was a limit? I guess there is.

查看更多
劫难
6楼-- · 2019-03-09 01:08

text-transform: capitalize; actually had no effect for me (it was happening on a tags), but this worked

text-indent: -9999px
float: left
display: block
font-size: 0
line-height: 0
overflow: hidden
查看更多
手持菜刀,她持情操
7楼-- · 2019-03-09 01:16

If nothing else works exactly right, this does:

color: transparent;
text-indent: 0 !important; /* reset the old negative value */

So normal browsers use the negative text-indent, ie7 gets special treatment using conditional comments

查看更多
登录 后发表回答