今天要项目要实现下图这样的效果,以前一直是用 ,但是转念一想,应该不会是这么粗暴的方式,肯定有更优雅的方式来实现这个,于是百度了一下,发现了正确的姿势代码如下
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> span{ width: 100px; text-align: justify; float: left; } span:after{ content:'.'; width: 100%; display: inline-block; overflow: hidden; height: 0; } input{ width: 100px; } </style> </head> <body> <div class="demo"> <span>昵称</span>:<input type="text" style = 'width: 100px'><br><br> <span>电子邮箱</span>:<input type="email" style = 'width: 100px;'> </div> </body> </html>
|