目录

Radio Switch

描述 (Description)

无线电开关用于从多个选项中仅选择一个选项。 您可以使用《input type = "radio"》来创建选项列表。

例子 (Example)

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

<html>
   <head>
      <title>Radio Switch</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
   </head>
   <body>
      <div>
         <div class = "switch">
            <input class = "switch-input" id = "exampleRadioSwitch1" type = "radio" checked name = "testGroup">
            <label class = "switch-paddle" for = "exampleRadioSwitch1">
               <span class = "show-for-sr">Radio Switch 1</span>
            </label>
         </div>
         <div class = "switch">
            <input class = "switch-input" id = "exampleRadioSwitch2" type = "radio" checked name = "testGroup">
            <label class = "switch-paddle" for = "exampleRadioSwitch2">
               <span class = "show-for-sr">Radio Switch 2</span>
            </label>
         </div>
         <div class = "switch">
            <input class = "switch-input" id = "exampleRadioSwitch3" type = "radio" checked name = "testGroup">
            <label class = "switch-paddle" for = "exampleRadioSwitch3">
               <span class = "show-for-sr">Radio Switch 3</span>
            </label>
         </div>
      </div>
      <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>

输出 (Output)

让我们执行以下步骤,看看上面给出的代码是如何工作的 -

  • 保存上面给出的html代码radio_switch.html文件。

  • 在浏览器中打开此HTML文件,输出显示如下。

新页面打开
↑回到顶部↑
WIKI教程 @2018