如何更改HTML span标题字体大小?

时间:2016-04-25 08:41:15

标签: html css

我试图更改span title元素的字体大小。我在google搜索好的例子,我找到了这个:link

但即使标题显示在灰色工具提示中,第二个显示: enter image description here

我的问题是:如何通过增加字体大小来设置第二个工具提示(黄色)的样式?

我的跨度如下:

<span title=${code} ></span>

2 个答案:

答案 0 :(得分:2)

I have test your fiddle, it seems that this problem happened only on FireFox. Simply you show 1 box (you content write in CSS) and the browser-standard title attribute, that appear on hover.

If you don't care about the real "title" attribute, you can use a work-around like this: http://jsfiddle.net/tDQWN/9078/

Just change 3 lines of code:

The output of your HTML:

<span title=${code} ></span>

And the CSS of the :after content:

a[data-title]:hover:after {
  content: attr(data-title);
  padding: 4px 8px;
  color: #333;
  position: absolute;
  left: 0;
  top: 100%;
  white-space: nowrap;
  z-index: 20px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0px 4px #222;
  -webkit-box-shadow: 0px 0px 4px #222;
  box-shadow: 0px 0px 4px #222;
  background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc));
  background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
}

In simple words, I have just change the "title" attribute in a "data-title" attribute. In this case, the browser don't output that small title text because it isn't a standard "title" attribute. Now you have to make the style of just one box.

答案 1 :(得分:2)

[title]:hover:after{
  content: attr(title);
  background:yellow;
  padding: 5px;
  border-radius:5px;
  border:1px solid;
}
<span title="jayeshshelar.com">Jayesh Shelar</span>