关于表单左右对齐

关于表单左右对齐的方法:

一:加入table标签,tr td等标签,td标签加上align="right"属性即可

转载于:https://www.cnblogs.com/5811yc/p/5942408.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个满足要求的表单示例代码: ```html <!DOCTYPE html> <html> <head> <title>表单示例</title> <style> /* 居中对齐 */ form { margin: 0 auto; text-align: center; } /* 表单标题样式 */ h2 { background-color: #ccc; padding: 10px; margin-top: 0; display: inline-block; } /* 表单样式 */ label { display: block; margin-bottom: 10px; } input[type=text], input[type=password] { padding: 5px; border: 1px solid #ccc; margin: 0 0 10px; width: 200px; box-sizing: border-box; } /* 表单边框样式 */ fieldset { border: 1px solid #ccc; padding: 20px; margin: 20px 0; } /* 提交按钮样式 */ input[type=submit] { background-color: #f00; color: #fff; padding: 10px; border: none; cursor: pointer; float: right; } input[type=submit]:hover { background-color: #c00; } </style> </head> <body> <form> <h2>用户登录</h2> <fieldset> <label> 用户名: <input type="text" name="username"> </label> <label> 密码: <input type="password" name="password"> </label> <input type="submit" value="提交"> </fieldset> </form> </body> </html> ``` 说明: - 通过 `margin: 0 auto;` 和 `text-align: center;` 让表单在页面中水平居中对齐。 - 用 `background-color` 和 `padding` 设置表单标题的背景色和内边距。 - 用 `display: inline-block;` 让表单标题和表单项在同一行并对齐。 - 用 `display: block;` 让表单项名称和表单项内容不在同一行。 - 用 `border` 设置表单边框样式。 - 用 `padding` 设置表单内容和表单边框之间的间距。 - 用 `float: right;` 让提交按钮右对齐。 - 用 `background-color` 和 `cursor: pointer;` 设置提交按钮的背景色和鼠标悬停时的光标样式
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值