| [点晴永久免费OA]input输入框添加内部图标
					当前位置:点晴教程→点晴OA办公管理信息系统
					
					→『 经验分享&问题答疑 』
					
				 
 有可能在制作网页的过程中遇到各种美化表单设计,这次我们来试着做一个demo,将input输入框添加内部图标。 话不多说,看一下最终效果: 我们的思路是,在一个div中,加入一个div和一个input标签,小div在左侧,input放右侧,用box-sizing:border-box,这句代码代表的是这个:怪异盒子模型 => 盒子定长定宽,不管有没有padding,border,margin,始终就是这么大,影响的只会是里面的元素。 左侧的div给border,也要给border-radius,右边的input只给右边的border,不给border-radius,input里面padding-left最好设置一下,更加美观。 总体思路其实是把大的div做成让人感觉像是一个input,如果能做到,那么你就成功了。 下面附代码: <div class="student-name-box"> <div> <img src="./img/学号.png" /> </div> <input type="text" value="" placeholder="请输入学号" /> </div> <div class="student-id-box"> <div> <img src="./img/密码.png" /> </div> <input type="password" placeholder="请输入密码" /> </div> CSS: .student-name-box,.student-id-box{
  box-sizing: border-box;
  width:300px;
  height:36px;
  border: 2px solid #DDD;
  border-radius: 5px;
  margin-top: 27px;
  margin-left: 50%;
  transform: translateX(-50%);
}
input{
  box-sizing: border-box;
  margin-bottom: 1px;
  outline: none;
  width:264px;
  height:32px;
  padding-left: 10px;
  border:;
}
.student-name-box div:first-child
  ,.student-id-box div:first-child{
  box-sizing: border-box;
  float: left;
  width: 32px;
  height: 32px;
  background: rgb(233,236,239);
  background-position:8px 10px;
  border-right: 2px solid #DDD;
}
.student-name-box img,.student-id-box img{
  width: 16px;
  height: 16px;
  margin:8px;
}该文章在 2023/5/17 19:09:04 编辑过 | 关键字查询 相关文章 正在查询... |