- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 Bootstrap 4,我在 Dropmenu 上放置了一个 css
样式:
.dropdown .dropdown-menu {
-webkit-transition: max-height 0.5s, opacity 0.2s 0.1s, visibility 0s 4s;
-moz-transition: max-height 0.5s, opacity 0.2s 0.1s, visibility 0s 4s;
-ms-transition: max-height 0.5s, opacity 0.2s 0.1s, visibility 0s 4s;
-o-transition: max-height 0.5s, opacity 0.2s 0.1s, visibility 0s 4s;
transition: max-height 0.5s, opacity 0.2s 0.1s, visibility 0s 4s;
max-height: 0;
display: block; /* this property */
overflow: hidden;
opacity: 0;
visibility: hidden;
}
.dropdown.show .dropdown-menu {
-webkit-transition: max-height 0.9s, opacity 0.2s, visibility 0s;
-moz-transition: max-height 0.9s, opacity 0.2s, visibility 0s;
-ms-transition: max-height 0.9s, opacity 0.2s, visibility 0s;
-o-transition: max-height 0.9s, opacity 0.2s, visibility 0s;
transition: max-height 0.9s, opacity 0.2s, visibility 0s;
max-height: 290px;
opacity: 1;
visibility: visible;
}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
问题是这个 display: block;
在移动设备上给了我一个不需要的底部边距:
我该如何解决?
最佳答案
dropdown-menu
最初设置为 display:none
并且它有一些样式,例如填充。当您添加 display:block
时,您将使填充产生一些效果,因为该元素现在正在显示,即使它的高度为 0
。要解决此问题,请添加 padding:0
并且您可以在下拉列表展开时再次添加它:
.dropdown .dropdown-menu {
transition: max-height 0.5s, opacity 0.2s 0.1s, visibility 0s 4s;
max-height: 0;
display: block; /**/
padding: 0; /*Added this*/
overflow: hidden;
opacity: 0;
visibility: hidden;
}
.dropdown.show .dropdown-menu {
transition: max-height 0.9s, opacity 0.2s, visibility 0s;
max-height: 290px;
opacity: 1;
visibility: visible;
padding: .5rem 0; /*Added this*/
}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
关于html - Dropmenu 上的属性 Display : block, 有问题。不需要的 margin ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52357080/
我想在不展开横幅图像的情况下创建下拉列表。我想在 meadiaquery 的标题下方显示下拉图像。现在定位 mobileMenu div 有问题 $(document).ready(function(
我创建了一个下拉菜单,但它不起作用: Menu
我正在使用 python+selenium 模拟下拉菜单中的单击选项 这是下拉菜单图片 enter image description here 这是 3 个不同选项的页面源 CHastelloy C
ul.ulDropMenu{ z-index: 2; } ul.ulDropMenu li{ list-style: none; position: relative; } ul.ulDropMenu
我如何设置 bootstrap 下拉菜单宽度 100%(从左到右)? 最佳答案 您可以在 中添加类似的内容并设置宽度 width: 295px !important; 或者您可以将此扩展用于下拉菜单
我正在使用 BootsFaces 在 JSF 元素中进行响应式 UI 渲染。 BootsFaces 的一切看起来都很酷。有了这个,UI 设计就容易多了。但与此同时,我发现可能没有足够的灵 active
请帮我写这个脚本。我试图将一些 php 代码链接到下拉菜单,但我没有任何反应.... 代码是: js代码: function loadDoc1() { var xhttp = new XM
这个问题在这里已经有了答案: Bootstrap 4: Multilevel Dropdown Inside Navigation (7 个答案) 关闭 3 年前。
/*.dropdownMenuLista { -webkit-transition: max-height 0.5s, opacity 0.2s 0.1s, visibility 0s 4s;
我有一个 CSS 文件,我必须在我的下拉菜单上使用它。问题是菜单不起作用:我看不到主标题下方的列表。在此示例中,该列表应该位于 My Home,[username] 下方。 您可以在下面找到 CSS
我尝试用 foundation.css 写一个导航栏,但是当鼠标移动时子菜单不显示。 问题是,如何在this webpage中显示test的子菜单? . 我尝试更改visibility、display
我有一个下拉菜单,当我单击链接时,我想转到页面 view_products.php,它应该会显示我在 cat=B1 中找到的所有产品。我想使用 jquery 将数据库中的结果加载到我的#content
我正在使用 Bootstrap 4,我在 Dropmenu 上放置了一个 css 样式: .dropdown .dropdown-menu { -webkit-transition: max-he
我试图用子菜单制作导航栏,但我一直收到 dropMenu 未定义,当我将鼠标悬停在两个巴黎链接上时,我收到 Uncaught TypeError: Cannot read property 'styl
我是一名优秀的程序员,十分优秀!