2012-10-03 57 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

哦,我喜欢这个!完善!有一个难以置信的位置旁边的其他图标,但我敢肯定,我将能够弄清楚:) –