Clickable label not working in IE 8

后端 未结 9 2128
Happy的楠姐
Happy的楠姐 2020-12-14 01:47

I\'ve got the following list item:

  • 9条回答
    •  爱一瞬间的悲伤
      2020-12-14 02:13

      I Guess I have a better hack solution for this problem. I will explain why for first.

      Using jquery to hit the label click works, but not when you are using an Input File, because you will receive access denied.

      Using css and display the image as a background it´s not good too because you need to have an image with the exactly size, which is not the case when the user uploads the Image or you have a lot of images with different sizes.

      Ok now I´ll explain the idea of the hack:

      You have a Label with an image inside, when you click the image, IE8 doesn´t fire the Label. But if you write some text into the Label, when you click the text IE8 fire the label.

      The Idea is to put a span inside the label, with the size of the label (width and height)

      Ok but if you don´t have text inside it won´t work, but if you change the background color it will work.

      So what you need to do is:

      1. Place a Span with the role size of the Label
      2. Write a background color and make it transparent
      3. Position the Span using relative position to put the Span exactly over the Label.

      It´s a little hard to do it, but I guess it will cover many more situations. An example of a Label firing the Input type File:

      
      

      I hope it works and save you Like it saved-me

    提交回复
    热议问题