html - 按顺序排列的 CSS 目标文本输入字段
问题描述
我有一个带有以下文本输入字段的 html 表单。没有class,没有id,同类型。
我需要以不同的方式设计它们。
是否可以使用纯 CSS 按顺序定位它们?
就像是:
CSS(不工作)
input[0] {
height: 100px;
}
input[1] {
height: 150px;
}
input[2] {
height: 200px;
}
<input name="arr[]" type="text">
<input name="arr[]" type="text">
<input name="arr[]" type="text">
我知道我可以使用:nth-child或:nth-of-type,但我想知道是否有另一种方法来定位这些元素,就像我的 CSS 示例中一样。
谢谢。
解决方案
试试 :nth-child,像这样:
input:nth-child(1) {
height: 100px;
}
input:nth-child(2) {
height: 150px;
}
input:nth-child(3) {
height: 200px;
}
推荐阅读
- flutter - Flutter:重置密码将我带到主页而不是返回登录页面
- security - 信号语音/视频加密方案
- node.js - 如何使用 Angular 和 Firestore 将数组发送到电子邮件
- spring - 使用 ldapTemplate 了解 REST 应用程序中的 spring 范围
- qt - 未调用 OnClosing 事件以最小化到托盘应用程序
- subdomain - 对同一服务器中的主域和子域使用不同的 cPanel 帐户
- docker - 每当新数据插入数据库时,如何安排容器运行?
- amazon-web-services - 如何添加单个单词调用名称alexa?
- xpages - 在寻呼机页面之间保留所选文档
- sql-server - 使用 TransactionScope 时获取 System.Reflection.TargetInvocationException