huige233's blog huige233's blog
首页
  • 技术文档
  • other
  • 学习笔记
  • 心情杂货
  • 友情链接
  • 收藏
  • 关于
  • 肯定有帮助 (opens new window)
  • CSDN (opens new window)
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

huige233

Disqualification humaine
首页
  • 技术文档
  • other
  • 学习笔记
  • 心情杂货
  • 友情链接
  • 收藏
  • 关于
  • 肯定有帮助 (opens new window)
  • CSDN (opens new window)
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 技术文档

  • CSS

    • CSS教程和技巧收藏
    • flex布局语法
    • flex布局案例-基础
    • flex布局案例-骰子
    • flex布局案例-圣杯布局
    • flex布局案例-网格布局
    • flex布局案例-输入框布局
    • CSS3之transition过渡
    • CSS3之animation动画
    • 「布局技巧」图片未加载前自动撑开元素高度
    • 文字在一行或多行时超出显示省略号
    • 从box-sizing属性入手,了解盒子模型
    • 水平垂直居中的几种方式-案例
    • 如何根据系统主题自动响应CSS深色模式
    • 「css技巧」使用hover和attr()定制悬浮提示
    • CSS-function汇总
  • other

  • 学习笔记

  • 编程内容
  • CSS
huige233
2019-12-25

flex布局案例-输入框布局

# flex布局案例-输入框布局

可用F12开发者工具查看元素及样式,可打开codepen在线编辑代码。

<html>
  <div class="InputAddOn">
    <span class="InputAddOn-item">icon</span>
    <input class="InputAddOn-field" placeholder="input宽度自适应">
    <button class="InputAddOn-item">提交</button>
  </div>
  <br/>
  <div class="Media">
    <div class="Media-figure">左侧固定</div>
    <p class="Media-body">右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应右侧自适应</p>
  </div>
</html>
<style>
  .InputAddOn {
    display: flex;
  }
  .InputAddOn-field {
    flex: 1;
  }
  .Media {
    display: flex;
    align-items: flex-start;
  }
  .Media-figure {
    width: 100px;
    height: 100px;
    background: #eee;
    margin-right: 1em;
  }
  .Media-body {
    flex: 1;
  }
  /* 基础样式 */
  input:-webkit-autofill,
  select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px white inset !important;
  }
  input {
    outline-color: invert;
    outline-style: none;
    outline-width: 0px;
    text-shadow: none;
    -webkit-appearance: none;
    -webkit-user-select: text;
    outline-color: transparent;
    box-shadow: none;
  }
  .InputAddOn-item {
    width: 100px;
    text-align: center;
    line-height: 30px;
    border: 1px solid #ccc;
    background: #eee
  }
  .InputAddOn-field {
    height: 30px;
    padding: 1px 6px;
    border: 1px solid #ccc;
    border-left: none;
    border-right: none;
  }
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

参考:http://www.ruanyifeng.com/blog/2015/07/flex-examples.html (opens new window)

编辑 (opens new window)
上次更新: 2021/09/18, 15:10:44
flex布局案例-网格布局
CSS3之transition过渡

← flex布局案例-网格布局 CSS3之transition过渡→

最近更新
01
huige的2023年年终总结
12-29
02
我的 Hackergame 2023 writeup
11-03
03
CSS星空炫技
01-20
更多文章>
Theme by Vdoing | Copyright © 2021-2024 huige233 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式