Basics

优质
小牛编辑
114浏览
2023-12-01

描述 (Description)

要创建标签,必须将.label类添加到元素中。 例如,您可以使用《span》标签甚至其他标签效果很好。 标签可用于描述另一个元素。 将两个元素绑定在一起可以通过提供标签,唯一ID并在主元素上引用aria-describedby属性中的ID来完成。

例子 (Example)

以下示例演示如何在Foundation中使用label

<html>
   <head>
      <title>Label Basics</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
   </head>
   <body>
      <span class = "label">Default</span>
      <p aria-describedby = "email">Re: re: A Christmas gift for you!</p>
      <span class = "label" id = "email">Maximum Priority</span>
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></script> 
      <script>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>

当多个标签描述元素时,您必须在aria-describedby放置多个ID。 有关更多信息,请浏览标签多个ID