2012-10-03 56 views
1

我試圖說出「我可用!」當我將鼠標懸停在它上面時,從左側滑出小「+」圖像。我在Google上找到的僅僅是沒有幫助。從懸停的圖像上使用CSS滑出文本

前 - enter image description here

我希望它懸停做什麼enter image description here

我也想提出,當鼠標懸停以及那個小「+」號側身翻,但我想我有一個關於如何自己做的想法。雖然不介意幫助:)

如果我可以用CSS/HTML做所有這些事情,那就太好了。我知道一些jQuery,但我試圖避免它,因爲CSS只是更乾淨。

+3

您可以發佈相關的HTML和CSS當你加號圖標,旋轉360度? – Blender

回答

2

如果你想讓它不使用jQuery只需旋轉使用css3動畫屬性:

這將使徘徊

@-webkit-keyframes rotate { 
    from { 
    -webkit-transform: rotate(360deg); 
    } 
    to { 
    -webkit-transform: rotate(0deg); 
    } 
} 

@-moz-keyframes rotate { 
    from 
    { 
     -moz-transform: rotate(360deg); 
    } 
    to { 
    -moz-transform: rotate(0deg); 
    } 
} 

.plusicon:hover 
{ 
    -webkit-animation-name:    rotate; 
    -webkit-animation-duration:   0.5s; 
    -webkit-animation-iteration-count: infinite; 
    -webkit-animation-timing-function: linear; 

    -moz-animation-name:    rotate; 
    -moz-animation-duration:   0.5s; 
    -moz-animation-iteration-count: infinite; 
    -moz-animation-timing-function: linear; 
} 

你也應該能夠使用-webkit-transition-duration: 1s;移動你的文字了

+0

我會開始說我還沒有真正嘗試過這個,所以這可以完全工作,但我一直在玩過渡屬性,無論出於何種原因,我的圈子會移動位置盤旋。 它會轉動,但它看起來好像是從頂部固定。我在解釋事物時非常糟糕,所以這裏有一個當你徘徊在它上面時它所做的事情的圖像 - http://i49.tinypic.com/s1uays。png 我正在尋找它看起來好像只有旋轉的「+」號,而不是圓。我甚至嘗試將該圓圈作爲背景圖像,但+符號最終做了同樣的事情 –

+0

整個事物看起來像旋轉的原因是由於圖像容器上的填充或邊距。如果圖像沒有位於包含旋轉的包裝中,那麼圖像看起來偏離中心,如果它居中,則整個圓也會旋轉,但它會保持原樣,因此只能看到+符號旋轉。 – LanFeusT

0

所以你想要某種形式的提示。

的HTML:

<a href="#"> 
    <span>I'm available!</span> 
</a> 

的CSS:

a { 
    background: url(../path_to_image.png) 0 0 no-repeat; /*you allready have that part */ 
    position: relative; 
} 
a span { 
    display: none; 
    position: absolute; 
    left: -10px; 
    top: 3px; 
} 
a:hover span { 
    display: block; 
} 

可以更換任何你有<a>標籤絲毫沒有

0

HTML:

<div class="slidebtn"> 
    <div class="icon"> 
     <div class="text"><p>I'm Aviable</p></div> 
    </div> 

</div>​ 

CSS:

.slidebtn{ 
    width:140px; 
    margin:auto; 
    overflow:hidden; 
    height:auto; 
    position:relative; 
} 
.text{ 
    position:absolute; 
    width:100px; 
    float:Left; 
    margin-left:150px; 
} 
.icon{ 
    background-image:url('http://cdn1.iconfinder.com/data/icons/icojoy/noshadow/standart/png/24x24/001_01.png'); 
    width:24px; 
    height:24px; 
    float:right; 
    background-repeat: no-repeat; 
    background-position: right; 

} 
.icon:hover{ 
    width:130px; 
} 
.icon:hover .text{ 
    margin-left:0px; 
} 
    ​ 

DEMO

,如果你想使用CSS3過渡轉變作風像這些

.text{ 
    position:absolute; 
    width:100px; 
    float:Left; 
    margin-left:150px; 
    -webkit-transition: all 1s ease-in-out; 
    -moz-transition: all 1s ease-in-out; 
    -o-transition: all 1s ease-in-out; 
    transition: all 1s ease-in-out; 
    z-index:-1; 
} 
.icon{ 
    background-image:url('http://cdn1.iconfinder.com/data/icons/icojoy/noshadow/standart/png/24x24/001_01.png'); 
    width:24px; 
    height:24px; 
    float:right; 
    background-repeat: no-repeat; 
    background-position: right; 
    -webkit-transition: all 1s ease-in-out; 
    -moz-transition: all 1s ease-in-out; 
    -o-transition: all 1s ease-in-out; 
    transition: all 1s ease-in-out; 

} 

DEMO 2

+0

這幾乎是我正在尋找的東西。這太糟糕了,我需要jQuery,但它會起作用!謝謝! –

+0

我改變了我的答案,看看也許它可以幫助你 – Afshin

+0

哦,我喜歡這個!完善!有一個難以置信的位置旁邊的其他圖標,但我敢肯定,我將能夠弄清楚:) –