Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Hyperlink with Image AND Text

Is it possible to make hyperlink looked like button WITH text on it?

We can make hyperlink button with code:

<a href="..."> <img src="button.png" width="100" height="50" alt="Some text"></img> </a>

but i need also TEXT in the center of button.

Thanks.

like image 722
Victor_Z Avatar asked Jul 05 '12 15:07

Victor_Z


1 Answers

I'd suggest, without knowing exactly what you want, and assuming the following mark-up:

<a href="#"><img src="path/to/image.png" /><span>Some text</span></a>

a {
    position: relative;
    display: inline-block;
}

a span {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -1em;
    margin-left: -50%;
    width: 100%;
    height: 2em;
    color: #f90;
    background-color: rgba(0,0,0,0.5);
}​

JS Fiddle demo.

like image 68
David Thomas Avatar answered Sep 28 '22 00:09

David Thomas