2011-07-04 27 views
2

私は、ライン上の画像を持つボタンのリンクを取得したいと考えています。画像上の背景の背景

I did、実際には、使用してCSS:

その後
section a:link, section a:visited { 
    width: 150px; 
    -moz-border-radius: 10px; 
    -webkit-border-radius: 10px; 
    border-radius: 10px; 
    -khtml-border-radius: 10px; 
    color: white; 
    background: #03c; 
    padding: 10px 10px 10px 60px; 
    display: block; 
    text-decoration: none; 
} 

section div { 
    margin-left: 5px; 
    margin-top: -9px; 
    width: 50px; 
    height: 50px; 
    float: left; 
} 

.pdf div { 
    background: transparent url('pdf.png') no-repeat 0 50%; 
} 

HTML:

<section class="pdf"> 
    <div></div> 
    <a href="#">Sheet music (PDF)</a> 
</section> 

しかし、負のマージンthat don't work in IE7を使用してより良い解決策がないのですか?私は特定のmargin-topsection aタグに入れようとしましたが、余白が崩壊したために動作しませんでした。

(うわー、私の評判は私が画像を埋め込むにも2つの以上の外部リンクを追加することはできませんでした。)

+0

あなたのテストケースは、 thirtydot

答えて

3

@jill。あなたのコードではリンクの外に画像を置くので、画像をホバーするとリンクが隠れます。私はあなたがそれを意図的に行うかどうかを知らない。絶対的なポジションを使用できるかもしれません。

HTML

<a href="#"><span>&nbsp;</span>Sheet music (PDF)</a> 

CSS

a{ 
    display:block; 
    position:relative; 
    text-decoration:none; 
    -moz-border-radius: 10px 10px 10px 10px;  
    background: none repeat scroll 0 0 #0033CC; 
    color: white; 
    padding: 10px 10px 10px 60px; 
    text-decoration: none; 
    width: 150px; 

} 
a span{ 
    display:block; 
    position:absolute; 
    background: url("http://www.jill-jenn.net/drafts/background-image-over-the-lines/pdf.png") no-repeat ; 
    width:50px; 
    height:50px; 
    top:-5px; 
    left:10px; 
} 
a:hover{ 
    background:red; 
} 

チェック http://jsfiddle.net/sandeep/AwkwF/ がものであってもよい。この例では、あなたの

0

を助けたり、ほぼすべてが同じである。このような何かを、してみてくださいですしかし、イメージバックkgroundは、spanタグである

<a href="#"><span>Sheet music (PDF)</span></a>