javascript - 在 React-JavaScript/CSS 中单击时下拉箭头向下移动
问题描述
我在理解这个问题上有点困难,我dropdown
在使用 ReactJS 时制作了菜单Nav-bar
,当我点击它时,它会显示下拉项目,但它也会移动下拉箭头的位置。我已尝试将高度和位置调整为absolute
但仍然相同,请提供任何建议/指针。
我更新了 CSS 设置,如下所示。
CSS设置:
.btn-group {
position: relative;
}
.btn-group >div {
position: absolute;
}
代码片段:
return (
<nav className="header">
<label className="logo">
<a href="/">
<img className="yoga-image" />
</a>
</label>
<ul>
<li>
<a href="./basket">
<i className="fa" style={{ "font-size": "24px" }} href="./basket">

</i>
<span class="badge badge-warning" id="lblCartCount">
{productItemInCart}
</span>
</a>
</li>
// the Signin/register button and dropdown code starts from here under the <li>
<li>
<button variant="success" href="./signin" style={{ background: "none", borderStyle: "none", borderStyle: "none", outline: "none " }}>
{userstatus ? (
<i
style={{ border: "none", background: "none", outline: "none" }}
className=" fas fa-user-circle
"
></i>
) : (
<i
style={{
"border": "none",
"background": "none",
"outline": "none",
"font-size": "1.8rem",
"fontFamily": "Roboto",
"textTransform": "none",
"marginLeft": "-3rem",
}}
>
Sign in/ Register
</i>
)}{" "}
</button>
// the below div define the drop down arrow
<div class="btn-group" style={{ minHeight: "15px", maxHeight: "15px", positiom: "fixed" }}>
<button
type="button"
class="btn btn-secondary dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded=" !important"
>
</button>
<div class="dropdown-menu dropdown-menu-right">
<button class="dropdown-item" type="button">
Action
</button>
<button class="dropdown-item" type="button">
Another action
</button>
<button class="dropdown-item" type="button">
Something else here
</button>
</div>
</div>
</li>
</ul>
</nav>
)
在任何点击之前:
我点击后:
解决方案
推荐阅读
- javascript - 如何从读取的 JSON 文件中更改值
- python - 等待:tcp://db:5432 等待依赖项变为可用 30 秒后超时:[tcp://db:5432]
- reactjs - 如何将动态道具传递给接受对象联合作为其类型的 React 组件?
- discord.js - 不和谐 JS | 服务器:检测重新加入的用户
- javascript - 将对象数组中的空值替换为先前填充的值
- illegalargumentexception - java.lang.IllegalArgumentException:无法从 START_OBJECT 令牌中反序列化 `java.lang.String` 的实例
- c# - EF Core 编译模型缓存过期
- sas - 平均平方误差和均方误差有什么区别?他们以同样的瘦而闻名吗?
- c# - 在 Blazor 中验证 URL 参数并以 404 响应
- ssh - ssh 卡在 debug1:已发送 SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192)