jquery - 为什么这个下拉列表超出窗口

标签 jquery html css

为什么这个下拉列表会超出窗口?

我正在使用 HTML + CSS3 + jQuery,我试图将下拉列表元素的位置更改为 fixedtop:0px 但它没有帮助!

我不明白为什么列表会超出页面,所以您正在等待有关此问题的最佳解决方案。

我需要你的帮助

$(document).ready(function(){

$('.menu').children().mouseenter(function(){


	$('.menu').children(this).find('div').fadeIn(500);


})

$('.menu').children().mouseleave(function(){


	$('.menu').children(this).find('div').fadeOut(500);


})

})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="menu">

  <div class="element">
      Smaller
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>

  </div>

</div>


    <script src='jquery-3.4.1.min.js'></script>
    <script src='jquery.js'></script>

$(document).ready(function(){

$('.menu').children().mouseenter(function(){


	$('.menu').children(this).find('div').fadeIn(500);


})

$('.menu').children().mouseleave(function(){


	$('.menu').children(this).find('div').fadeOut(500);


})

})
.menu
{
  display: flex;
  flex-direction: row;
  align-items: center;
  border: 1px solid black;
  background-color: #08298A;
  color: white;
  height: 50px;
  max-height: 50px;
}

.element 
{
  background-color: #0A0A2A;
  top: 0px;
  padding: 0px;
  margin: 0px;
}

.element div
{
  display: none;
  padding: 10px;
  background-color: #045FB4;
  border: 1px solid white;

}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="menu">

  <div class="element">
      Smaller
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>

  </div>

</div>

<div class="menu">

  <div class="element">
      Smaller
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>
      <div>Paragraph 1</div>

  </div>

</div>



$(document).ready(function(){

$('.menu').children().mouseenter(function(){


$('.menu').children(this).find('div').fadeIn(500);


})

$('.menu').children().mouseleave(function(){


$('.menu').children(this).find('div').fadeOut(500);


})

})

最佳答案

它是 .menu 规则中的 align-items: center。这与 display: flex 结合意味着它将尝试将子 .element 垂直居中。在这种情况下,没有足够的空间,所以它的一部分显示在屏幕外。

关于jquery - 为什么这个下拉列表超出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56604190/

相关文章:

javascript - jQuery 显示/隐藏在 WordPress 中不起作用

html - 如何使用 htaccess 强制使用 http- 而不是 https

javascript - 将json结构转换为jquery angularjs中的嵌套json结构

javascript - 在 JavaScript 中使用 CSS Grid repeat() 声明

html - 在 Chrome td 边框底部重叠

javascript - jquery 使用 $.on 来添加 dom 元素?

javascript - 不要重复上次使用的图像

javascript - 在文本区域内获取第一个 block 引用

php - 在 Javascript 文件中在屏幕上打印 html 输入属性和变量

html - 在悬停时添加边框时如何防止移动? (透明边框不是解决方案)