简体   繁体   English

选择位置更改时如何对齐选择框

[英]How to align select and select box while select's position changed

I found a fun problem with the native html select element. 我发现原生html select元素有一个有趣的问题。 when you click the select, after it the select's position change, but the box under the select won't change it's position to align with it. 当您单击选区时,选区的位置会更改,但是选区下方的框不会更改以使其对齐的位置。

在此处输入图片说明

Here is a simple code sample. 这是一个简单的代码示例。

 (() => { setTimeout(() => { document.getElementById('span').innerText = "Test of metal"; }, 3000) })() 
 <div> <span id="span"></span> <select> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </div> 

how to make the box align with the select itself? 如何使框与选择本身对齐? Is there any solution? 有什么解决办法吗?

Try this: 尝试这个:

  (() => { setTimeout(() => { document.getElementById('span').innerText = "Test of metal", document.getElementById('select_id'); }, 3000) })() 
 <div> <span id="span"></span> <select id="select_id"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </div> 

change the 3000 value to faster the text shows up 3000值更改为更快的文本显示速度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM