Why Do Images Still Have Borders in Chrome and IE9, Even with \'border: none;\'?

Barbara Streisand
Release: 2024-11-03 14:38:30
Original
844 people have browsed it

Why Do Images Still Have Borders in Chrome and IE9, Even with

Chrome and IE9 Border Suppression Techniques

Removing the unsightly border that persists around images in Chrome and IE9 can be a frustrating task. Despite setting border properties to "none," these browsers stubbornly maintain a thin line.

Potential Causes and Solutions:

  • Chrome Bug: Chrome ignores the "border:none;" style, particularly for images with specific dimensions. To circumvent this, trick Chrome into perceiving no image presence by assigning zero width and height, coupled with precise padding values to accommodate the desired image size.
  • IE9 Behavior: IE9 adds a pixel-thin selection border around images when the image is clicked. To eliminate this, disable the "user-select" property.

Example Implementation:

CSS for Chrome Bug:

<code class="css">#dlbutn {
    display:block;
    width:0px;
    height:0px;
    outline:none;
    padding:43px 51px 43px 51px;
    margin:0 auto 5px auto;
    background-image:url(/images/download-button-102x86.png);
    background-repeat:no-repeat;
}</code>
Copy after login

CSS for IE9 Selection Border:

<code class="css">img {
    -ms-user-select:none;
    user-select:none;
}</code>
Copy after login

Additional Tips:

  • Ensure the image is not wrapped in any other elements with borders.
  • Check for vendor prefixes that may be influencing the border appearance.
  • Try disabling hardware acceleration temporarily to see if it affects the border behavior.

The above is the detailed content of Why Do Images Still Have Borders in Chrome and IE9, Even with \'border: none;\'?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template