美文网首页
Tailwind Input

Tailwind Input

作者: JunChow520 | 来源:发表于2020-05-30 20:17 被阅读0次

基础输入框

无边框

无边框输入框主要使用了shadow阴影,适合在有底色的环境中使用。

无边框
<input type="text" class="relative outline-none rounded px-2 py-1 w-full bg-white shadow text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:shadow-outline" placeholder="placeholder" />
样式 属性
relative position:relative;
outline-none outline:0;
px-2 py-1 padding:.25rem .5rem;
w-full width:100%;
bg-white background-color:white;
shadow box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
text-sm text-gray-700 font-size:.875rem; color:#b83280;

placeholder-gray-400实际的类名全程为.placeholder-pink-400::placeholder表示文本占位符的颜色color: #f687b3;

伪类 样式 属性
focus outline-none outline:0;
focus shadow-outline box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);

带边框

带边框取消了阴影shadow取而代之的是border,适合在纯色背景中使用。

白底带边框
<input type="text" class="relative outline-none border border-gray-400 rounded py-1 px-2 w-full bg-white text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:shadow-outline" placeholder="placeholder"/>
样式 属性
relative position:relative;
outline-none outline:0;
border border-gray-400 round -
px-2 py-1 padding:.25rem .5rem;
w-full width:100%;
bg-white background-color:white;
shadow box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
text-sm text-gray-700 font-size:.875rem; color:#b83280;

输入框尺寸

input size
标识 尺寸 样式 属性
small 小型 py-1 px-2 text-sm padding:.25rem .5rem; font-size:.875rem;
regular 普通 py-3 px-3 text-sm padding:.75rem; font-size:.875rem;
large 大型 py-4 px-3 text-base padding:1rem .75rem; font-size:1rem;
<input type="text" class="relative outline-none rounded py-1 px-2 w-full bg-white shadow text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:shadow-outline" placeholder="placeholder" />

<input type="text" class="relative outline-none rounded py-3 px-3 w-full bg-white shadow text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:shadow-outline" placeholder="placeholder" />

<input type="text" class="relative outline-none rounded py-4 px-3 w-full bg-white shadow text-base text-gray-700 placeholder-gray-400 focus:outline-none focus:shadow-outline" placeholder="placeholder" />

输入框图标

输入框左右侧的图标采用Flex弹性容器和绝对定位结合方式实现

input with icon

左侧图标

input with left icon
<div class="relative mb-3 w-full flex flex-wrap items-stretch">
  <span class="absolute z-10 py-3 pl-3 w-8 h-full leading-snug bg-transparent rounded text-base font-normal text-gray-400 text-center flex items-center justify-center">
    <i class="fa fa-lock"></i>
  </span>
  <input type="text" class="relative py-1 px-2 pl-10 w-full bg-white rounded shadow outline-none text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:shadow-outline" placeholder="placeholder" />
</div>

右侧图标

input with right icon
<div class="relative mb-3 w-full flex flex-wrap items-stretch">
  <input type="text" class="relative py-1 px-2 pr-10 w-full bg-white rounded shadow outline-none text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:shadow-outline" placeholder="placeholder" />
  <span class="absolute right-0 z-10 py-1 pr-2 w-8 h-full leading-snug bg-transparent rounded text-base font-normal text-gray-400 text-center flex items-center justify-center">
    <i class="fa fa-user"></i>
  </span>
</div>

源代码地址

https://codepen.io/junchow/pen/eYpqWQE?editors=1000

参考UI

https://www.creative-tim.com/learning-lab/tailwind-starter-kit/presentation

相关文章

  • Tailwind Input

    基础输入框 无边框 无边框输入框主要使用了shadow阴影,适合在有底色的环境中使用。 样式属性relativep...

  • 使用React和Tailwind CSS搭建项目框架

    众所周知,Tailwind CSS框架越来越流行,所以我决定尝试学习并使用Tailwind CSS来搭建一个项目模...

  • 使用SASS模仿TailwindCSS生成常用CSS样式

    最近维护MPX小程序项目发现没有基础样式库,由于MPX版本比较老不兼容tailwind库,用惯了tailwind后...

  • Tailwind Table

    表格样式工具类 表格布局table layout CSS中table-layout属性用于设置表格布局的类型,即用...

  • Tailwind Base

    添加基础样式 - 使用Tailwind添加全局的基础样式 全局基础样式是样式表开头的样式,用于为基础HTML元素设...

  • Tailwind Effects

    Tailwind特效 阴影shadow 不透明度opacity 阴影shadow 这里的阴影特指CSS3中新增的b...

  • Tailwind SVG

    什么是SVG呢? SVG(Scalable Vector Graphics)是一种可伸缩矢量图形 SVG基于可扩展...

  • Tailwind Component

    按钮(button) 带符号的按钮 输入框(input) 普通输入框 邮箱输入框 文本域(textarea) 搜索...

  • Tailwind Transform

    CSS3中transform(变形)属性用于设置元素在2D或3D上的旋转、缩放、移动和倾斜 坐标系 transfo...

  • CSS Tailwind

    一般的UI中CSS框架都是内建各种预设的组件,比如按钮、卡片、警告框等,当需要通过定制化设计时,组件的高度耦合性则...

网友评论

      本文标题:Tailwind Input

      本文链接:https://www.haomeiwen.com/subject/hmrhzhtx.html