gpt4 book ai didi

html - 如何删除菜单中的间距

转载 作者:太空宇宙 更新时间:2023-11-04 07:26:31 24 4
gpt4 key购买 nike

我正在使用在此站点上找到的菜单示例。这是 jsfiddle .该示例显示了页面的背景颜色和菜单栏的另一种背景颜色。在我的网站上,颜色将是相同的。但是当颜色相同时,总和菜单项出现在主菜单项下方太远。有人可以解释一下我如何删除该空间,以便子元素(如 Splash Tasks)位于主元素(如 Splash Mode)的正下方吗?

下面是使用的代码:

    <style>
@font-face {
font-family: "Yeezy";
src: url("../static/yeezy.ttf");
}

* {
font-family: "Yeezy";
font-weight: bold;
color: #dbdbdb !important;
}

html,
body {
height: 900px;
background-size: cover;
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.4) 100%), url("https://i.imgur.com/pxYxnOn.jpg");
}
.navbar {
overflow: hidden;
background-color: rgba(0, 0, 0, 0.2);
}

/* Links inside the navbar */
.navbar a {
float: left;
font-size: 15px;
color: rgba(0, 0, 0, 0.4);
text-align: center;
padding: 14px 16px;
text-decoration: none;
}


/* The dropdown container */

.dropdown {
float: left;
overflow: hidden;
}

/* Dropdown button */
.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: rgba(0, 0, 0, 0.2);
padding: 17px 13px;
background-color: inherit;
font-family: inherit;
/* Important for vertical align on mobile phones */
margin: 0;
/* Important for vertical align on mobile phones */
}
/* Add a red background color to navbar links on hover */
.navbar a:hover,
.dropdown:hover .dropbtn {
}

/* Dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
box-shadow: 0px 0px 16px -20px rgba(0, 0, 0, 0.1);
z-index: 1;
}

/* Links inside the dropdown */
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

/* Add a grey background color to dropdown links on hover */
.dropdown-content a:hover {
background-color: rgba(0, 0, 0, 0.2);
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
</style>

<body>
<div class="navbar navbar-default">
<a href="#home">Home</a>
<div class="dropdown">
<button class="dropbtn">Splash Mode</button>
<div class="dropdown-content">
<a href="splashtasks">Splash Tasks</a>
<a href="h2splash">How to use Product Mode</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Product Mode</button>
<div class="dropdown-content">
<a href="producttasks">Product Tasks</a>
<a href="h2product">How to use Product Mode</a>
</div>
</div>
</div>
</body>

最佳答案

.dropdown-content a:first-child {
padding-top: 0;
}

这将删除下拉菜单中第一个元素的顶部填充

在 css 中,您在此处为下拉元素留出空间:

.dropdown-content a {
...
padding: 12px 16px;
...

关于html - 如何删除菜单中的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49843129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com