gpt4 book ai didi

css - 下拉并在右侧对齐

转载 作者:行者123 更新时间:2023-11-28 00:44:00 25 4
gpt4 key购买 nike

我正在使用这个下拉菜单,它向下与左侧的按钮对齐,但我希望它以相反的方式向下,因为它在移动设备上不在屏幕上。我附上了图片以显示它正在做什么以及我正在努力让它做什么。

<div class='dropdown'>
<button class='dropbtn'>Hi, Anthony &#9660;</button>
<div class='dropdown-content'>
<a href='index.php?c=my-profile'>My Golfer Profile</a>
<a href='index.php?c=my-schedule'>My Schedule</a>
<a href='index.php?c=account-settings'>Account Settings</a>
<div style='width:100%;border-bottom: 1px #000 dotted;'>&nbsp;</div>
<a href='actions/logout.php'>Logout</a>
</div>
</div>


.dropbtn {
background-color: #3D5C7F;
color: white;
padding: 12px;
font-size: 14px;
border: none;
cursor: pointer;
border-radius: 3px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3D5C7F;
}

what it does

enter image description here

what I need it to do

enter image description here

最佳答案

由于您没有发布您的 HTML 代码,我不知道哪个类应用于您的下拉列表的起始元素。如果 dropdown-content 类应用于下拉列表的起始元素,请添加以下样式以及您已应用于类 dropdown-content 的样式:

.dropdown-content {
right: 0;
left: auto;
}

如果您也发布您的 HTML,我们可以提供更好的帮助。

关于css - 下拉并在右侧对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53644659/

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