2012-07-05 75 views
2

我有一个A标签我试图添加一个类。这可能很简单,但我从来没有这样做过。标签类不工作

<a class="button" href="landscaping.html">Find out more about our landscape design services</a> 

而CSS:

a .button{ 
color:#7cc242; 
font-family: 'PTSansNarrowBold'; 
font-size:18px; 
margin-top: 7px; 
margin-bottom: 0px; 
text-align:right; 
text-decoration:none; 
display: inline-block; 
zoom:1; 
*display:inline; 
padding-right:30px; 
background:url(images/more-btn.png) no-repeat top right;} 

似乎没有什么是工作,我刚开始的标准蓝色。谁能帮忙?

回答

8

应该没有空间!请更改:

a .button{ 

到:

a.button{ 

退房小提琴这里:http://jsfiddle.net/VhaNQ/

+2

太谢谢你了!哦,我知道这会是这些愚蠢的问题之一。感谢帮助我看到这个盲目明显! – Francesca 2012-07-05 10:24:17

4

你在CSS说的是:“我希望所有的孩子button类,所有a的标签来使用下一个CSS规则“。

你需要说的是“我希望标签a与类button使用下一个CSS规则”。

这是通过写入下一个CSS实现:

a.button{ 
    color:#7cc242; 
    font-family: 'PTSansNarrowBold'; 
    font-size:18px; 
    margin-top: 7px; 
    margin-bottom: 0px; 
    text-align:right; 
    text-decoration:none; 
    display: inline-block; 
    zoom:1; 
    *display:inline; 
    padding-right:30px; 
    background:url(images/more-btn.png) no-repeat top right; 
} 

注意有标签/班/ IDS之间a.button

空间之间没有空格指 “元素的孩子”。

祝你好运:)从a .button

+0

+1为解释。谢谢。 – JerryOL 2013-08-27 15:44:42

3

除去空间这样a.button或使用简单的.button