gpt4 book ai didi

html - 如何定位下拉菜单

转载 作者:太空宇宙 更新时间:2023-11-04 01:37:00 25 4
gpt4 key购买 nike

我有一个带有选项卡的菜单,由于某种原因不想靠近菜单的左侧。我尝试删除所有其他填充内容等,但它并没有影响菜单边缘和选项卡文本之间奇怪的额外空间。

另外,我想让下拉菜单在 ul li ul li 标签周围没有填充,只有父标签本身。下图左边是当前元素 https://codepen.io/gracethelittleartist/pen/EvMbNR?editors=1100 ) 右边显示了我想要的样子。 enter image description here

ul{list-style:none;}
a{ text-decoration: none;color: black;}

.ul-li {position: relative;}

ul li {padding:10px;}

.ul-li > .ul-li-ul {max-height: 0;transform: scaleY(0);}

.ul-li > input[type="checkbox"] {
opacity: 0;
display: block;
position: absolute;
top: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
.ul-li > input[type="checkbox"]:checked ~ .ul-li-ul {
max-height: 9999px;
display: block;
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-webkit-transform: scaleY(1);
transform: scaleY(1);
}


.ul-li {position: relative;}
.ul-li > .ul-li-ul {
max-height: 0;
overflow: hidden;
list-style: none;
padding: 0;
margin: 0;
transform: scaleY(0);
transform-origin: 50% 0%;
transition: transform 0s ease-out 0.6s,max-height 0.6s ease-out;
}

.ul-li > .ul-li-ul li a {
display: block;
background: #E3E3E3;
padding: 10px 10px;
}
.ul-li > .ul-li-ul li a:hover {background: #D1D1D1;}

.ul-li > input[type="checkbox"] {
opacity: 0;
display: block;
position: absolute;
top: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
.ul-li > input[type="checkbox"]:checked ~ .ul-li-ul {
max-height: 900px;
display: block;
transform: scaleY(1);
animation: showAnimation 0.5s ease-in-out;
transition: max-height 2s ease-in-out;
}
.ul-li > input[type="checkbox"]:checked + a[data-toggle="dropdown"]:before {
transition: transform 0.6s;
}

nav ul li:not(.search):hover {background: white;}

@keyframes hideAnimation {
0% {transform: scaleY(0.5);}
60% {transform: scaleY(0.25);}
80% {transform: scaleY(0);}
100% {transform: scaleY(0);}
}

.wrap {
position: relative;
z-index: 1;
background: #E8E8E8;
max-width: 330px;
margin: 0 auto;
}

最佳答案

你的问题是这样的:

ul li {padding:10px;}

如果您仅为父级指定此项,则一切正常。提示:使用 Google Chrome 的检查功能来(取消)激活 CSS 样式。

关于html - 如何定位下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46042393/

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