[英]I need to hide a placeholder when focusing an input but showing instead the label of that input
I have been looking for how to fix this, I have applied scss and css, also javascript.我一直在寻找如何解决这个问题,我已经应用了 scss 和 css,还有 javascript。 I need my input to show a placeholder when it opens normally and when you focus on it it will display its label and look small as in this photo I have.
我需要我的输入来显示一个占位符,当它正常打开时,当你专注于它时,它会显示它的 label 并且看起来像我的这张照片一样小。
https://i.stack.imgur.com/VxEqE.jpg https://i.stack.imgur.com/VxEqE.jpg
This is the input code and the label I'm handling serves me any code, ts, js, css, html.这是输入代码,我正在处理的 label 为我提供任何代码、ts、js、css、html。
<label> Contraseña </label>
<input placeholder='Ingrese su contraseña...' [class.isinvalid]="loginForm.controls.contrasena.invalid && (loginForm.controls.contrasena.dirty || loginForm.controls.contrasena.touched || isSubmited)">
<div *ngIf="loginForm.controls.contrasena.invalid && (loginForm.controls.contrasena.dirty || loginForm.controls.contrasena.touched || isSubmited)">
<small *ngIf="loginForm.controls.contrasena.hasError('required')">La contraseña es requerido</small>
</div>
</div>
You can find this in angular material library, if you are planning to use in your project with more options.如果您打算在项目中使用更多选项,您可以在 angular 材料库中找到它。 https://material.angular.io/components/form-field/overview#form-field-overview
https://material.angular.io/components/form-field/overview#form-field-overview
Else, you can build your custom input from this post.否则,您可以从这篇文章构建您的自定义输入。
Move placeholder above the input on focus 将占位符移到焦点上的输入上方
you don't have to hide the placeholder & you can't.你不必隐藏占位符,你不能。 you can do it easily --
你可以轻松做到——
document.getElementById("mytext").focus();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.