简体   繁体   English

HTML选择框显示在chrome中的windows任务栏下方

[英]HTML select box is displaying below windows task bar in chrome

I am trying to add an html dropdown using the select tag and unfortunately in chrome I am unable to select option 5 and 6 as they are being displayed below the task bar in chrome on windows. 我正在尝试使用select标签添加html下拉列表,不幸的是在chrome中我无法选择选项5和6,因为它们显示在Windows上的chrome任务栏下方。 If I add an option 7 then suddenly the list displays above instead of below. 如果我添加选项7然后突然显示上面而不是下面的列表。 在此输入图像描述

This list will always be changing sizes so unfortunately positioning the list higher will not be an option as there is always the possibility of 2 options being hidden. 此列表将始终更改大小,因此不幸的是,将列表放在更高位置将不是一个选项,因为总有可能隐藏2个选项。 Furthermore, the number of items displayed in the list is before a scroll bar is added is browser specific. 此外,列表中显示的项目数是在添加滚动条之前是浏览器特定的。 See Height of an HTML select box (dropdown) 查看HTML选择框的高度(下拉列表)

What I've tried so far: 到目前为止我尝试过的:

  • Tried converting the dropdown list to a static list when there are more than 4 options using jquery and setting list size. 当使用jquery和设置列表大小超过4个选项时,尝试将下拉列表转换为静态列表。 This however was very ugly. 然而这非常难看。
  • Tried using bootstraps .dropup class but this unfortunately only works with list items not select options 尝试使用bootstraps .dropup类但不幸的是这只适用于列表项而不是选择选项
  • Different css hacks but as mentioned earlier the list size is browser specific. 不同的css hacks但是如前所述,列表大小是浏览器特定的。

I would rather not add in any external libraries and find some kind of simple Jquery hack to fix this. 我宁愿不添加任何外部库,并找到一些简单的Jquery黑客来解决这个问题。 You can also see what I mean by visiting this jsfiddle link and dragging the display window to the bottom of the screen: 您还可以通过访问此jsfiddle链接并将显示窗口拖动到屏幕底部来查看我的意思:

  <div class="form-group">
  <label for="sel1">Select list:</label>
  <select class="form-control" id="sel1">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
     <option>6</option>
  </select>
</div>

https://jsfiddle.net/v9t4rm16/ https://jsfiddle.net/v9t4rm16/

Looks like this is an official chrome bug It affects Chrome Version 30-61 看起来这是一个官方的Chrome错误它会影响Chrome版本30-61

I do not think there is an official work around. 我认为没有正式的工作。

If you do not want to wait for the chrome fix, then you could try: 如果您不想等待Chrome修复,那么您可以尝试:

  • Adding white to the bottom of your page so the select has space to expand 将白色添加到页面底部,以便选择具有展开的空间
  • Adding extra options in the select itself to force chrome to render upwards 在select本身中添加额外选项以强制chrome向上渲染

对于表单组和表单控件类,将z-index设置为1000

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

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