html – 如何使用CSS在输入元素后添加换行符?

html – 如何使用CSS在输入元素后添加换行符?,第1张

概述我正在使用一种服务,该服务通过一系列标签和输入返回动态 HTML,例如 input:after { content: "\a"; white-space: pre;} <label for="username">Username</label><input type="text" id="username" name="username" /><label for="country 我正在使用一种服务,该服务通过一系列标签和输入返回动态 HTML,例如
input:after {  content: "\a";  white-space: pre;}
<label for="username">Username</label><input type="text" ID="username" name="username" /><label for="country">Country</label><input type="text" ID="country" name="country" />

我希望表单格式如下:

但它不起作用.不能使用div包围标签和输入,因为这是由服务返回给我的动态HTML.

任何想法如何只能通过CSS实现?

解决方法 替换了元素,包括< img>,< object>,< input>和< textarea> …没有:before和:after伪元素.

作为解决方法,您可以在< label>上设置换行符.元件.

label:before {    content: "\a";    white-space: pre;}
<label for="username">Username</label><input type="text" ID="username" name="username" /><label for="country">Country</label><input type="text" ID="country" name="country" />
总结

以上是内存溢出为你收集整理的html – 如何使用CSS在输入元素后添加换行符?全部内容,希望文章能够帮你解决html – 如何使用CSS在输入元素后添加换行符?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1118201.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存