【小程序】input输入框属性及上下左右居中的示例(图文+代码)

属性功能示例

placeholder

输入框空时,提示文字 placeholder=“请输入用户名”
placeholder-style输入框,提示文字的样式

placeholder-style=

"color:rgb(170,170,170);

margin-left: 20px;"

placeholder-classplaceholder 的样式类用class样式修改
cursor-spacing指定的光标与弹出键盘的距离

cursor-spacing="50"

type

text:文本输入

idcard:身份证输入键盘

digit:带小数点的数字键盘

nickname:昵称输入键盘

password密码格式
disabled只读,禁用输入

disabled="false"

maxlength最大输入长度,设置为 -1 的时候不限制最大长度maxlength=“-1”
focus获得焦点

focus="true"

在view中的垂直居中

display: flex;align-items: center;

在view中的左右水平居中

display: flex;justify-content: center;

官方文档:

input | 微信开放文档微信开发者平台文档https://developers.weixin.qq.com/miniprogram/dev/component/input.html

二、实例1

    <view class="boxNumber">

        <view>¥</view>
        <view>
            <input type="digit" placeholder="请输入金额" placeholder-class="boxNumberInput" adjust-position="true">
            </input>
        </view>
    </view>

二、实例2,文本框和文本框组合

 文本框

wxml文件

<view class="text">
    <input type="text" required="required" placeholder="请输入手机号" placeholder-style="color:rgb(170,170,170);">
    </input>
</view>

 wxss代码

    .text {
        height: 60px;
        width:94%;
        margin: 0 auto;
        display: flex;
        text-align: center;
        justify-content: center;
        /* background-color:red; */
        margin-bottom: 10px;
    }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

敦厚的曹操

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值