【发布时间】:2020-06-23 21:17:16
【问题描述】:
我有一个包含多个输入的内联表单。
在较大的设备中,我想使用 'label' 来指示字段类型,但在较小的设备中,
我想使用“placeholder”来节省空间。对于“标签”,我可以使用引导类 d-none 和 d-sm-block。
如何有条件地为较小的设备显示“占位符”?
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css">
</head>
<body>
<form class="form-inline">
<label class="control-label d-none d-sm-block mr-2" for="id1">Country</label>
<input type="text" id="id1" placeholder="input country">
</form>
</body>
</html>
【问题讨论】:
-
在较大的设备上显示占位符也没有什么坏处。默认情况下,占位符将出现在小型和大型设备上。如果你仍然想要这个 - 你需要使用 jQuery 或 Javascript 来让你的占位符隐藏在较大的设备上并显示在小型设备上。
标签: html css twitter-bootstrap