简体   繁体   English

没有图像的文本翻转效果

[英]Text Rollover Effect without Images

I have a phone number link at the top of my website, the number is 1300 GO POOPIES. 我的网站顶部有一个电话号码链接,数量为1300 GO POOPIES。 (for example purposes :P) (例如:P)

<h1 class="phone-text">
<a href="tel:+6113007667437">1300 GO POOPIES</a>
</h1>

So basically, when a person puts their mouse over the 1300 GO POOPIES it changes to 1300 46 7667437. 所以基本上,当一个人将他们的鼠标放在1300 GO POOPIES上时,它会变为1300 46 7667437。

I don't want to use an image however as I want to preserve the click-to-call functionality. 我不想使用图像,因为我想保留点击通话功能。

I tried to do something with CSS, with minimal success however. 我尝试用CSS做一些事情,但成功率很低。

.phone-text::after {
  content: "1300 GO POOPIES";
}

.phone-text:hover:after {
  content: "1300 76 67437";
}

not sure if this is out of the boundaries of css, and needs java... 不确定这是否超出了css的界限,需要java ...

You don't even need to load jQuery or JS. 你甚至不需要加载jQuery或JS。 CSS+HTML only. 仅限CSS + HTML。 FIDDLE 小提琴

If there is a reason for you avoiding JavaScript, then this can be achieved with just CSS if you're willing to add some extra markup. 如果您有理由避免使用JavaScript,那么只要您愿意添加一些额外的标记,就可以通过CSS实现。 You do so by putting two elements inside the <a> tag, one with the numeric number, one with the alphanumeric number. 您可以在<a>标记内放置两个元素,一个使用数字编号,一个使用字母数字编号。 Then you can hide/show them independently with a:hover selectors. 然后,您可以使用a:hover选择器独立隐藏/显示它们。

HTML HTML

<h1 class="phone-text">
  <a href="tel:+6113007667437">
    <span class="letters">1300 GO POOPIES</span>
    <span class="digits">1300 76 67437</span>
  </a>
</h1>​

CSS CSS

.phone-text a .digits,
.phone-text a:hover .letters {
  display: none;
}

.phone-text a .letters,
.phone-text a:hover .digits {
  display: inline;
}

jsFiddle 的jsfiddle

You want something a little more in depth... Here goes. 你想要更深入的东西......这就是。

Html HTML

<a href="tel:+6113007667437">
  <div id="hide">
    <h1>1300 76 67437</h1>
  </div>
  <div>
    <h1>1300 GO POOPIES</h1>
  </div>
</a>

And your css 而你的CSS

div{
 position:absolute;
 background:#ffffff;
}
div#hide:hover{
 display:none;
}

Try this: 试试这个:

$('a').hover(
  function(){
    $(this).text('1300 76 67437')
  },
  function(){
    $(this).text('1300 GO POOPIES')
  }
});

怎么样这个http://jsfiddle.net/tzerb/S52bz/ <a class =“phone-text”href =“tel:+6113007667437”> </ a>

here you have a variation to the solution proposed by yaponyal . 在这里,您对yaponyal提出的解决方案有所不同 it works without the > sign. 它没有>符号。

.hiden {
display:none;
}
a:hover .shown {
display:none;
}
a:hover .hiden {
display:inline;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM