0

I have an img tag with no src content:

<img class="logo" src="" alt="" />

I can't change the src content because it is automatically generated by my company framework.

This is my logo class:

.logo {
    background: url('img/logo.png') no-repeat center center;
    background-size: 70%;
    margin-top: 25px;
    border: 0;
    border-style: none;
}

But on Chrome, I get this strange border on my image. How can I remove that?

logo with border

aseolin
  • 1,184
  • 3
  • 17
  • 35
  • Some other css class might be adding the border. Try adding important to your border property. `border:0!important;` – Ozgur Sar Nov 25 '20 at 12:48
  • I tried with no success. This is only happening on Chome – aseolin Nov 25 '20 at 12:49
  • If possible, can you share the URL that has the logo? – Ozgur Sar Nov 25 '20 at 12:49
  • I'm sorry, it is on a local environment – aseolin Nov 25 '20 at 12:53
  • Using Chrome Dev Tools, you can check the calculated values for the logo element and play with the values to check what causes the border. – Ozgur Sar Nov 25 '20 at 12:58
  • https://stackoverflow.com/questions/6013071/removing-the-image-border-in-chrome-ie9 Check out this and try the 2nd answer by Randy. This solved many issues withr andom Borders in Chrome for me. Fooling chrome into thinking there is nothing and use padding to display the content. – Warden330 Nov 25 '20 at 13:03
  • It happens with any replacement for the logo img so it's not dependent on seeing the company logo @ozgur. – A Haworth Nov 25 '20 at 13:03
  • Does this answer your question? [What's the valid way to include an image with no src?](https://stackoverflow.com/questions/5775469/whats-the-valid-way-to-include-an-image-with-no-src) – 0stone0 Nov 25 '20 at 13:32

3 Answers3

0

Might be Outline or box shadow property

Try

.logo { 
   outline: none !important;
   box-shadow: none !important
}
Vishal
  • 235
  • 1
  • 15
0
. logo {
   border: none;
} 

or

. logo {
   border-color: transparent;
} 

or

.logo {
   border: 0px solid transparent;
0

I'm posting this answer as a Javascript alternative to css solution (if any)

You can target the logo class img and change its src programmatically. This code should run after the logo has been added to DOM.

// Fix the img url here according to your real path    
document.getElementsByClassName[0]("logo").src="img/logo.png";

If there are more than one logo class on the page, the code should be modified accordingly though.

Ozgur Sar
  • 2,067
  • 2
  • 11
  • 23