2013-03-01 51 views
-1

我有以下代码会产生一个徽标徽标显示它在正确的位置,但a href=""不工作,为什么?CSS背景不可点击 - a href =“”不工作

HTML:

<div class="banner"> 
    <span><a href="<?php echo BASE_URL()?>link" title="View information about award"></a></span> 
</div> 

CSS:

div.banner{ 
      width:592px; 
      height:1px; 
      position: fixed; 
      top:0; 
      right:0; 
      overflow: visible; 
     } 
     div.banner span{ 
      display: block; 
      position: fixed; 
      top: 0; 
      right: 0; 
      background: url(../../../i/ribbon.png) top right no-repeat; 
      width: 197px; 
      height: 145px; 
      text-indent: -999em; 
     } 
     div.opens span a{ 
      display:block; 
      width: 197px; 
      height: 145px; 
     } 
+4

Shouldn't它是'div.banner跨度了',而不是'div.opens跨越了'? – insertusernamehere 2013-03-01 19:29:48

+0

比“不工作”更具描述性会更好 – 2013-03-01 19:31:21

+0

你对链接有什么意义? – caramba 2013-03-01 19:31:48

回答

3

您的链接类应该是div.banner span a而不是div.opens span a。所以你的链接没有文字,因为没有宽度,因为CSS规则不适用。所以没有什么可点击的。

+0

谢谢:)我需要另一组眼睛 – 2013-03-01 19:33:06

0

可能你需要像这样

<div class="banner"> 
    <span> 
      <a href="<?php echo BASE_URL().'/thisFile.html'; ?>" title="View information about award"> 
      This is the link to the file 
      </a> 
    </span> 
</div> 
0

DEMO on jsfiddle

我想,我不能告诉你为什么你的代码是没有具体工作,但我看到了一些东西也可能是。 ..这是我将如何接近它。如果您将整个横幅设置为链接,那么点击页面上的一些文本可能会更容易点击一下。

你并不需要一个正式的包装器,但为了保持事物的模块化,它可以帮助你在不同的环境中反复使用这些横幅类。

如果我不能解决问题,请告诉我,我会尽力引导回来。

HTML

<div class="fixed-wrapper"> 

    <a class="banner" href="#"> 

     Some words for robots and for assistive text ?   

     <span class="open">a different image I'm assuming?</span> 

    </a> <!-- end .banner --> 

</div> <!-- end .fixed-wrapper --> 

CSS

.fixed-wrapper { 
    position: fixed; 
    top: 0; right: 0; 
} 

.banner { 
    position: relative; 
    display: block; 
    width:592px; 
    height:145px; 

    background-color: #f06; 
} 

.banner { 
    text-indent: -999em; 
} 

.open { 
    display:block; 
    position: absolute; 
    top: 0; right: 0; 
    width: 197px; 
    height: 145px; 

    background-color: orange; 
} 

.banner:hover .open {  
    background-color: yellow; 
} 

/* i assume that your .open does something... */ 

DEMO on jsfiddle