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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .info { display: flex; flex-direction: column; margin: 50px; width: 158px; height: 80px; position: relative; }
.con { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; width: 150px; height: 30px; line-height: 30px; padding-left: 5px; border-top: 1px solid #ccc; border-left: 1px solid #ccc; box-shadow: 1px 1px 2px 0px rgb(0, 0, 0); margin-bottom: 10px; position: relative; top: 0; }
.con::after { content: ''; width: 0px; height: 0px; border-top: 10px solid rgb(0, 0, 0); border-right: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 5px solid transparent; position: absolute; bottom: -15px; left: 5px; z-index: 1; }
input { width: 150px; height: 30px; position: absolute; bottom: 0; } </style> </head>
<body> <div class="info"> <div class="con">123</div> <input type="text" placeholder="请输入您的快递单号" class="jd"> </div> <script> var con = document.querySelector('.con') con.style.display = 'none' var input = con.nextElementSibling input.addEventListener('keyup', function (e) { if (input.value == '' || input.value == null) { con.style.display = 'none' } else { con.style.display = 'block' con.innerHTML = input.value } })
document.addEventListener('keyup', function (e) { if (e.keyCode === 83 || e.keyCode === 115) { input.focus(); } })
input.addEventListener('blur', function () { con.style.display = 'none'; }) input.addEventListener('focus', function () { if (this.value !== '') { con.style.display = 'block'; } })
</script> </body>
</html>
|