Jump to content

Image as Link


shadowx360

Recommended Posts

Hello,

 

I'm using an image as a link, and I basically create a new image element, set its source, create an "a" element, set it's href, and then I append the image as a child to the link. However, what I get is a button with a blue outline, as links are blue, and it automatically makes that blue outline on the button. I tried to force the border-color property to black (that's the background color of the page), but it still gives me that blue outline.

 

Any idea how to disable that, or turn it black?

Link to comment
https://forums.phpfreaks.com/topic/214449-image-as-link/
Share on other sites

Do as suggested and set it in your CSS and not your JavaScript.  Regardless of how you're creating them the CSS rules will be obeyed.  If you start putting CSS in your JavaScript you are combining logic and presentation and making it harder to fix things later.

 

The CSS rule you're looking for is:

a > img { border: none; }

 

Or if necessary:

a > img { border: none !important; }

Link to comment
https://forums.phpfreaks.com/topic/214449-image-as-link/#findComment-1116029
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.