欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  使用HTML5+CSS3来创建淡入效果的提示框步骤
 
  步骤一:设置一个基础提示框
 
  代码如下
 
  
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>PHP中文网</title>
 
  </head>
 
  <style>
 
  .tooltip{
 
  position:relative;
 
  display:inline-block;
 
  border-bottom:1pxdottedblack;
 
  }
 
  .tooltip.tooltiptext{
 
  visibility:hidden;
 
  width:120px;
 
  background-color:black;
 
  color:#fff;
 
  text-align:center;
 
  border-radius:6px;
 
  padding:5px0;
 
  /*定位*/
 
  position:absolute;
 
  z-index:1;
 
  }
 
  .tooltip:hover.tooltiptext{
 
  visibility:visible;
 
  }
 
  </style>
 
  <bodystyle="text-align:center;">
 
  <divclass="tooltip">鼠标移动到这
 
  <spanclass="tooltiptext">提示文本</span>
 
  </div>
 
  </body>
 
  </html>
 
  效果如图所示
 
  b.gif
 
  步骤二:使用CSS3transition属性及opacity属性来实现提示工具的淡入效果
 
  代码如下
 
  
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>PHP中文网</title>
 
  </head>
 
  <style>
 
  .tooltip{
 
  position:relative;
 
  display:inline-block;
 
  border-bottom:1pxdottedblack;
 
  }
 
  .tooltip.tooltiptext{
 
  visibility:hidden;
 
  width:120px;
 
  background-color:black;
 
  color:#fff;
 
  text-align:center;
 
  border-radius:6px;
 
  padding:5px0;
 
  position:absolute;
 
  z-index:1;
 
  bottom:100%;
 
  left:50%;
 
  margin-left:-60px;
 
  /*淡入-1秒内从0%到100%显示:*/
 
  opacity:0;
 
  transition:opacity1s;
 
  }
 
  .tooltip:hover.tooltiptext{
 
  visibility:visible;
 
  opacity:1;
 
  }
 
  </style>
 
  <bodystyle="text-align:center;">
 
  <h2>淡入效果</h2>
 
  <p>鼠标移动到以下元素,提示工具会再一秒内从0%到100%完全显示。</p>
 
  <divclass="tooltip">PHP中文网
 
  <spanclass="tooltiptext">666666666666</span>
 
  </div>
 
  </body>
 
  </html>






 

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css3-style/c55403.shtml