2013-09-27 86 views
0

enter image description here如何將「+」向右移動?

我的Css如下,我嘗試向右移動「+」圖標但未能移動它,任何人都可以幫忙嗎?

.button-sec-icon { 
    background-color: #fdfdfd; 
    cursor:pointer; 
    background: transparent url("images/basicsetup/plus.png") no-repeat left!important; 
    margin-right: 5px; 
    border: 2px solid #EEEEEE; 
    border-radius: 5px 5px 5px 5px; 
    box-shadow: 0 3px 1px rgba(0, 0, 0, 0.2); 
    color: #ca2b2b; 
    display: block; 
    height: 28px; 
    margin: 10px 0 0 60px; 
    transition: all 0.5s ease 0s; 
    min-width: 150px; 
    width: 121px; 
} 


.button-sec-icon:hover { 
    border :1px solid #888; 
    box-shadow: 0 4px 1px rgba(0, 0, 0, 0.2); 
} 
+1

您使用了兩次保證金標籤。 「保證金」和「保證金」。刪除第一個「保證金 - 權利」,看看會發生什麼。 – jbrya029

+0

@ n00b,你是正確的保證金正確的問題。我想接受你的回答,但你在評論:) – tsohtan

+0

這是什麼'.button-sec-icon'類名是指?它是指按鈕還是其他元素?下面的答案假設類名引用了按鈕元素。也發佈您的相關的html代碼.. –

回答

0

您使用的保證金標籤的兩倍。 「保證金」和「保證金」。刪除第一個「保證金 - 權利」,看看會發生什麼。

1

你可以設置背景位置右上角嗎?

background: transparent url("images/basicsetup/plus.png") top right no-repeat !important; 

或者即使你需要它跨越了一下,用百分比或固定寬度:

background: transparent url("images/basicsetup/plus.png") 0 5% no-repeat !important; 
background: transparent url("images/basicsetup/plus.png") 0 5px no-repeat !important; 
+1

我認爲OP想要移動背景圖像一點權利,但不完全正確。但我不確定。 「_icon右邊有點_」 –

+0

好點,它的確如此。已更新的明確寬度示例 – CodingIntrigue

0
background-position: 10px 0px; 

這應該做的伎倆,背景位置可以通過多種方式來使用。 採取在這裏閱讀:

http://www.css3.com/css-background-position/

+0

僅在plus爲背景圖像時才起作用。 – FaddishWorm

+1

@FaddishWorm這裏有一個提示:'background:transparent url(「images/basicsetup/plus.png」)' – CodingIntrigue

2

您需要使用background-position

background: transparent url("images/basicsetup/plus.png") no-repeat left!important; 

因此,而不是使用left的,使用

background-position: 10px 0; /* Parameters are X and Y respectively */ 
+0

我試過改變X的值我可以看到它在Chrome瀏覽器中上下移動,但是當我改變它不動,任何想法? – tsohtan

+0

@tsohtan http://jsfiddle.net/LXDFF/根據您的需要設置參數'px' –