html form width,HTML form input width

可以将文章内容翻译成中文,广告屏蔽插件会导致该功能失效:

问题:

I have this code below which is a simple html form. What i'm trying to do is make all of the inputs have max widths inside the form-panel and look something like the image below.

I tried setting max-width for all the inputs inside the panel but it doesn't seem to be working. Any help would be greatly appreciated.

re5RD.png

input[type="text"],

input[type="email"],

input[type="password"] {

padding: 4px 20px;

height: 35px;

border: 1px solid black;

margin: 10px;

border-radius: 3px;

max-width: 100%;

}

.form-panel {

display: table;

background-color: #b7bcbe;

}

回答1:

You can use flex-box instead of table.

As you use display: table - the column will have the same width (there is no colspan option)

Use display: flex for each columns and set flex-grow: 1 so that all elements will grow up and fill the parent.

input[type="text"],

input[type="email"],

input[type="password"] {

padding: 4px 20px;

height: 35px;

border: 1px solid black;

margin: 10px;

border-radius: 3px;

flex-grow: 1;

}

.form-row {

flex-direction: row;

display: flex;

}

.form-panel {

background-color: #b7bcbe;

}

回答2:

You have written common css for all input elements..write separate css for that particular input field and put important.

input[type="text"],

input[type="email"],

input[type="password"] {

padding: 4px 20px;

height: 35px;

border: 1px solid black;

margin: 10px;

border-radius: 3px;

max-width: 100%;

}

.form-panel {

display: table;

background-color: #b7bcbe;

}

回答3:

just add this line:

.form-email input {width: calc(100% - 20px);}

^--------[margin-left + margin-right]

input[type="text"],

input[type="email"],

input[type="password"] {

padding: 4px 20px;

height: 35px;

border: 1px solid black;

margin: 10px;

border-radius: 3px;

max-width: 100%;

}

.form-panel {

display: table;

background-color: #b7bcbe;

}

.form-email input {width: calc(100% - 20px);}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值