Foundation 提示框
提示框在滑鼠移到元素上後顯示:
我們可以在任何元素上新增 data-tooltip
屬性來建立提示資訊。使用 title
屬性來設定提示訊息的文字。
注意: 滑桿需要使用 JavaScript。所以你需要初始化 oundation JS:
實例
<!DOCTYPE html> <html> <head> <title>Foundation 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css"> <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script> </head> <body style="padding:20px;"> <h2>提示框</h2> <span data-tooltip title="php中文网">鼠标移到我这!</span> <a href="#" data-tooltip class="button" title="www.php.cn">鼠标移到我这!</a> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
#執行實例»
點擊"運行實例" 按鈕查看線上實例
.has-tip
類別可以加粗滑鼠移動的文字:
實例
<!DOCTYPE html> <html> <head> <title>Foundation 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css"> <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script> </head> <body style="padding:20px;"> <h2>Tooltips</h2> <span data-tooltip title="php中文网">鼠标移到我这!</span> <span data-tooltip class="has-tip" title="php中文网">鼠标移到我这!</span> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
運行實例»
點擊"運行實例" 按鈕查看線上實例
#提示框顯示位置
預設情況下,提示框會出現在元素的底部。 可以使用
.tip-top 在小尺寸的螢幕上,提示框的寬頻是 100%。實例
<!DOCTYPE html>
<html>
<head>
<title>Foundation 实例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css">
<script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script>
<script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script>
<script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script>
</head>
<body style="padding:20px;">
<h2>提示框</h2>
<p>默认情况下,提示框会出现在元素的底部。</p>
<p>可以使用 <code>.tip-top</code>, <code>.tip-left</code>, <code>.tip-right</code> or <code>.tip-bottom</code> (默认) 来设置提示框的位置。</p>
<p><strong>注意:</strong> 在小尺寸的屏幕上,提示框的宽带是 100%。</p>
<span data-tooltip class="has-tip tip-top" title="php中文网!">顶部</span>
<span data-tooltip class="has-tip tip-bottom" title="php中文网!">底部</span>
<span data-tooltip class="has-tip tip-left" title="www.php.cn">左边</span>
<span data-tooltip class="has-tip tip-right" title="www.php.cn">右边</span>
<!-- 初始化 Foundation JS -->
<script>
$(document).ready(function() {
$(document).foundation();
})
</script>
</body>
</html>
運行實例»
實例
<!DOCTYPE html> <html> <head> <title>Foundation 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css"> <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script> </head> <body style="padding:20px;"> <h2>圆角提示框</h2> <p> <code>.radius</code> 和 <code>.round</code> 类用于设置圆角提示框:</p> <span data-tooltip class="has-tip" title="php中文网!">默认</span> <span data-tooltip class="has-tip radius" title="php中文网!">圆角</span> <span data-tooltip class="has-tip round" title="php中文网!">圆形</span> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>