javascript - 在 Safari 中,下拉选项位于顶部

标签 javascript html css safari

<div id="growDiv"></div>
<select id="combobox">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
  <option>6</option>
  <option>7</option>
  <option>8</option>
  <option>9</option>
  <option>0</option>
</select>

<script>
  $('#growDiv').on('mouseover', function (){
    $(this).css('height', '200px');
  }).on('mouseout', function (){
    $(this).css('height', '75px');
  })
</script>

<style>
    #growDiv {
      width: 300px;
      height: 50px;
      background-color: gold;
      position: absolute;
      z-index: 1000;
    }

    #combobox {
      margin-top: 75px;
    }
</style>

您可以在以下位置看到它: http://jsfiddle.net/dHN2K/

在 Safari 中,如果我展开下拉选项然后将“悬停”在黄色的 div 上,选项会保持在顶部......我该如何解决这个问题?

我也试过 $('select').remove();但它仍然存在!!

谢谢!

最佳答案

您可以在鼠标悬停时隐藏选择。 http://jsfiddle.net/dHN2K/2/

查看我所做的更改。

  $('#growDiv').on('mouseover', function (){
    $(this).css('height', '200px');
      $("#combobox").hide();
  }).on('mouseout', function (){
    $(this).css('height', '75px');
       $("#combobox").show();
  })

关于javascript - 在 Safari 中,下拉选项位于顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14874566/

相关文章:

html - 如何让出现在表格边框和表格背景之间并让页面背景透出的烦人的1px边框消失?

javascript - 模块化网页设计

javascript - Google map : geocode addresses asynchronously, 但按顺序获取他们的响应

javascript - 除非单击,否则选项卡不会出现

javascript - 在 HTML canvas 上一条接一条地绘制连续的线条

javascript - -JS - 触摸-防止水平滚动

html - Bootstrap 移动导航栏宽度

javascript - 预加载层的问题 - 网站

javascript - 使用 colorbox 加载外部 url 然后 chop

jQuery - 带有CSS动画的淡入淡出错误