Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 浮动标签文本框样式的文本框文本隐藏_Html_Css - Fatal编程技术网

Html 浮动标签文本框样式的文本框文本隐藏

Html 浮动标签文本框样式的文本框文本隐藏,html,css,Html,Css,我想将表单中文本框的标签转换为浮动样式。我已经对输入框的悬停和焦点执行了操作。这里的问题是,当标签浮动并向上移动时,文本将被隐藏 这是我迄今为止尝试过的HTML和CSS .float标签{ 位置:绝对位置; 左:0; 排名:0; 填充:10px 6px; 颜色:#7676; 指针事件:无; 过渡:0.2s缓解所有; } .form控件:focus~.float标签, .form控件:非(:焦点):有效~.float标签{ 顶部:-18px; 左边距:5px; 字体大小:12px; 不透明度:1

我想将表单中文本框的标签转换为浮动样式。我已经对输入框的悬停和焦点执行了操作。这里的问题是,当标签浮动并向上移动时,文本将被隐藏

这是我迄今为止尝试过的HTML和CSS

.float标签{
位置:绝对位置;
左:0;
排名:0;
填充:10px 6px;
颜色:#7676;
指针事件:无;
过渡:0.2s缓解所有;
}
.form控件:focus~.float标签,
.form控件:非(:焦点):有效~.float标签{
顶部:-18px;
左边距:5px;
字体大小:12px;
不透明度:1;
z指数:1;
背景色:白色;
}

工作电子邮件

尝试执行以下更改:

.form-group{
  margin-top:20px;
  position:relative;
}
.float-label {
  position: absolute;
  left: 0;
  top: 0;
  padding:0;
  color: #767676;
  pointer-events: none;
  transition: 0.2s ease all;
}

尝试执行以下更改:

.form-group{
  margin-top:20px;
  position:relative;
}
.float-label {
  position: absolute;
  left: 0;
  top: 0;
  padding:0;
  color: #767676;
  pointer-events: none;
  transition: 0.2s ease all;
}

您可以使用
:显示的占位符
伪类。如果您不想使占位符文本
color:transparent
,您可以将标签和占位符的样式完全像素匹配

。表单组{
位置:相对位置;
填充:20px;
}
.浮动标签{
位置:绝对位置;
左:25px;
顶部:21px;
颜色:#7676;
指针事件:无;
过渡:0.2s缓解所有;
}
输入::占位符{
颜色:透明;
}
.form控件:focus~.float标签,
.form控件:非(:焦点):有效~.float标签,
输入:不(:显示占位符)~.浮点标签{
顶部:5px;
字体大小:12px;
不透明度:1;
z指数:1;
背景色:透明;
}

工作电子邮件

您可以使用
:显示的占位符
伪类。如果您不想使占位符文本
color:transparent
,您可以将标签和占位符的样式完全像素匹配

。表单组{
位置:相对位置;
填充:20px;
}
.浮动标签{
位置:绝对位置;
左:25px;
顶部:21px;
颜色:#7676;
指针事件:无;
过渡:0.2s缓解所有;
}
输入::占位符{
颜色:透明;
}
.form控件:focus~.float标签,
.form控件:非(:焦点):有效~.float标签,
输入:不(:显示占位符)~.浮点标签{
顶部:5px;
字体大小:12px;
不透明度:1;
z指数:1;
背景色:透明;
}

工作电子邮件
使用以下代码: Html:

使用此代码: Html:


你可以用这个链接来做浮动标签:实际上那不符合我的要求你的要求我在这里创建了一个小提琴你可以在这里找到浮动标签的例子:你可以用这个链接来做浮动标签:实际上那不符合我的要求你的要求我在这里创建了一个小提琴你可以找到浮动标签示例:@tkamath99您能再解释一下吗?谢谢,如果你在这里说/张贴你将来为他人解决问题的方式,那就太好了。@tkamath99你能再解释一下吗?谢谢,如果你在这里说/张贴你将来为别人解决问题的方式,那就太好了。
.textinput {
  height: 3em;
  margin: 1em 0;
  position: relative;
  width: 100%;
}

.textinput input,
.textinput label {
  cursor: text;
  font-size: 1.5em;
  padding: 0.6em 1% 0.15em 1%;
  position: absolute;
  transition: all 0.15s ease;
  width: 98%;
}

.textinput input {
  border: solid black 1px;
  border-radius: 0.15em;
}

.textinput label {
  color: #BCB9B8;
  padding: 0.5em 1%;
}

.textinput input.filled ~ label,
.textinput input:focus ~ label {
  font-size: 0.6em;
  font-weight: 600;
  position: absolute;
}

.textinput input.filled ~ label {
  color: #007932;
}

.textinput input[type="text"].filled,
.textinput input[type="email"].filled:valid {
  background: #B8DB9B;
}

.textinput input[type="text"].filled ~label:after,
.textinput input[type="email"].filled:valid ~label:after {
  color: #007932;
  content: "\f058";
  display: inline-block;
  font: normal normal normal 14px/1 FontAwesome;
  font-size: 3em;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: absolute;
  top: 0.3em;
  right: 0.3em;
  transform: translate(0, 0);
}