Problem with absolute positioning in Firefox and Chrome

前端 未结 9 2207
傲寒
傲寒 2020-12-14 17:05

I don\'t understand why FF and Chrome render my page differently. Here\'s a screenie of it in

firefox: firefox example http://grab.by/65Bn

and here\'s one i

相关标签:
9条回答
  • 2020-12-14 17:42

    It appears that Firefox has an invisible padding or margin that places the element at the top right of the text space. Chrome is placing the element at the top right of the fieldset element outside of the flow of text.

    One thing you could do is add a div wrapper and then absolutely position the element in the top right of the wrapper so that it lays over the corner of the fieldset.

    0 讨论(0)
  • 2020-12-14 17:42

    Instead of using margin use left, top, right, bottom. Example:

    position: absolute; top: 10px; left: 20px;

    0 讨论(0)
  • 2020-12-14 17:42

    I had a similar problem with a web site and the images in Chrome where wrong. I had the position in an image and an input box in the same way as your example at the beginning of this post, and I solved it by putting the absolute position in the input box and in the image position in relative coordinates.

    When I do that, it changes both positions but puts margins in both. I got it where I want it, to solve this problem with Firefox an Chrome you have to follow some of these tricks in order to put the images in the right place. Play with the position to make it work.

    0 讨论(0)
  • 2020-12-14 17:45

    I think it is because you didn't indicate the height of the div (passenger-info) that contains the button; Chrome starts acting up when you don't specify this.

    0 讨论(0)
  • 2020-12-14 17:46

    Using a feature query against one of mozilla's platform-native properties is probably the correct approach for this in 2020. -moz-appearance is one such property, but others would work as well.

    @supports (-moz-appearance: none) {
     .remove-me {
        border:1px solid red;
        position:absolute;
        right:0;
        top:0;
      }
    }
    
    0 讨论(0)
  • 2020-12-14 17:53

    I can't believe this is 4 years old and still not answered. I searched every where for this answer. Here is what I did to use position absolute on an image within a fieldset. From here, change your right and top positioning to make it work for you in Firefox. (leave your original class in place for IE, Chrome, Safari, Opera)

    @-moz-document url-prefix() { 
      .remove-me {
        border:1px solid red;
        position:absolute;
        right:0;
        top:0;
      }
    }
    

    This is a Firefox Hack that I'm told works for every version of Firefox. I'm using Firefox Version 33.0.2, so I can't confirm this works on older versions. I had the same problem on my site. It looked the same in IE, Opera, Safari, and Chrome. It was only in Firefox I noticed the positioning different. This works!

    0 讨论(0)
提交回复
热议问题