javascript - CSS:透明图像叠加输入字段
问题描述
我一直在尝试将这个透明徽标放在输入字段上,但我无法将它放在左侧。谁能指导我如何实现这一目标?提前致谢 :)
<div className={classes.formClass}>
<h3 className={classes.active}>Sign Up</h3>
<h3 className={classes.notActive} onClick={this.switchAuthModeHandler}>
Log In
</h3>
<div>
{/* <img src={require("../../assests/ic_username@2x.png")} alt="" /> */} [the image logo]
<input
type="text"
placeholder="Username"
name="username"
onChange={(event) => this.inputChangedHandler(event, "username")}
/>
</div>
</div>
CSS:
.formClass {
display: block;
position: relative !important;
margin-left: auto;
margin-right: auto;
}
.formClass img {
position: absolute;
margin-left: 50%;
margin-right: 30%;
top: 12px;
height: 24px;
width: 24px;
left: 20px;
right: 10px;
}
.formClass div input {
height: 52px;
width: 360px;
border-radius: 0px;
opacity: 30%;
margin-bottom: 12px;
}
解决方案
添加position:absolute
到您的图像类。它将根据您的需要将图像定位在您的输入中。
推荐阅读
- java - java.lang.ClassCastException:java.util.LinkedHashMap 无法转换为 com.example.backendtest.Project
- c - 具有多个文件的项目中的 CMakeLists.txt
- c# - 哪种是使用委托的正确方法?
- android - 使用firebase电话身份验证验证失败
- java - A-star算法java实现讲解
- java - 在外部 jframe 中显示 java 控制台
- php - PHP fetchAll(PDO::FETCH_ASSOC) 在语句中返回 null
- admin-on-rest - TabbedForm - 在 FormTab 上有条件地显示工具栏(提交按钮)
- json - 如何在组件之间共享通过订阅组件获得的数据
- jquery - 页面加载后添加活动类