html - 如何防止文本在选择框中被截断?
问题描述
我有一个很长的选项,我需要与整个选择框一起正确显示。如果将宽度设置为 100%,然后选择第一个选项,文本将被截断。当宽度设置为自动时,没有滚动条,这是一个问题,因为我需要选择框适合另一个元素。
这段代码来自我一直用来检查更改的 w3schools 教程,因为它比使用 localhost 更快,因为网站已经启动并且这只是调试。
<!DOCTYPE html>
<html>
<body>
<style>
#selection {
width: auto;
overflow: scroll;
}
option {
display: block;
}
</style>
<select id="selection" multiple>
<option value="volvo">If they are able to help ask them to wash themselves. You may give them step by step instructions such as, 'sit down' 'here is the cloth' 'wash your arm' etc. If they cannot, ask them to ‘help’ by holding the towel.</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
</body>
</html>
解决方案
推荐阅读
- c# - 将 c# 代码转换为 PHP 时出现问题,如下所示
- javascript - Is there a way to html elements appear with css styling from the very beggining that they load onto the page?
- javascript - wasm 可以使用 sysinfo 依赖吗?
- kubernetes - 具有 CRD 资源和 CRD 对象的 Kubernetes Yaml
- shell - 从 OSX 上的 curl 中提取响应代码和特定标头的一部分
- sql-server - SQL Server 编程错误:关键字“SELECT”附近的语法不正确
- angular - 角'nativeElement'未定义
- reactjs - 映射双嵌套 JSON - React Child 中不允许的对象
- java - 使用 gradle 导入 mongodb - 产生无法解析符号 'mongodb'
- android - 从 google sheet 转换为 android strings file.xml