了解下Foundation 表单

Crq
Crq
管理员
1967
文章
0
粉丝
Linux教程评论23字数 397阅读1分19秒阅读模式
摘要Foundation 表单控制会自动设置为全局样式

所有 <textarea>, <select>及 <input>元素宽度都为 100%,且带有外边距、内边距、阴影和鼠标移动效果。

实例

<form>
  Input:
  <input type="text" placeholder="Name">
  Textarea:
  <textarea rows="4" placeholder="Address"></textarea>
  Select:
  <select>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
  </select>
</form>
标签

在表单中使用 <label> 元素来设置标签,标签可以添加 for 属性和 id 属性。用户在点击标签或输入域时获取输入框焦点:

实例

<form>
  <label for="name">Input
    <input type="text" placeholder="Name" id="name">
  </label>
  <label for="adr">Label
    <textarea rows="4" placeholder="Address" id="adr"></textarea>
  </label>
  <label for="num">Select
    <select id="num">
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
    </select>
  </label>
</form>

如果需要设置标签右对齐,可以使用 .right 类:

实例

<label class="right">
Fieldset

Foundation 渲染 <fieldset> 元素的样式如>下:

实例

<form>
  <fieldset>
    <legend>Fieldset Legend</legend>
    <label>Name
      <input type="text" placeholder="First Name..">
    </label>
    <label>Email
      <input type="text" placeholder="Enter email..">
    </label>
  </fieldset>
</form>
错误状态

使用 .error 类来设置错误的标签、输入框、文本框样式:

实例

<form>
  <label class="error">Error
    <input type="text" placeholder="Name..">
  </label>
  <small class="error">Wrong input</small>
  <textarea rows="4" placeholder="Address"></textarea>
  <small class="error">Wrong input</small>
</form>

历史上的今天
3月
24
weinxin
我的微信
微信号已复制
我的微信
这是我的微信扫一扫
 
Crq
  • 本文由 Crq 发表于2025年3月24日 06:43:18
  • 转载请注明:https://www.cncrq.com/13574.html
【技术快报】8.16-8.22 Linux教程

【技术快报】8.16-8.22

本期《linux就该这么学》的技术周报中,将为您推出关于恢复计算机崩溃数据的五款最佳Linux发行版、Win10如何隐藏Windows Defender任务栏图标、5 个最受人喜爱...
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证