javascript - 像模型一样打开一个对话框,但附加到元素上
问题描述
我是 React Js 的新手,我想打开一个下拉框,其中可能包含按钮、输入字段等,但问题是我尝试了模型下拉列表和许多解决方案,但它并没有完全附加到元素开口的底部单击它时的下拉菜单。另一个问题是它包含的组件的最大高度只有 50 像素,因此模型应该漂浮在该组件上。
在附加的图像中,单击打开时该框正在打开,并且上方的蓝色条状组件包含代码,但它同时显示在两者上
只想要可以包含元素的框,并且正好位于打开它的元素下方
import React from "react"
import UserTopBar from "./UserTopTab"
import BelowSection from "./BelowSection"
const Parent =()=>{
<UserTopBar />
<BelowSection />
}
export default Parent
//顶栏
import React from 'react';
import Notification from '../Notification'
import { NavLink } from 'react-router-dom'
import { QuestionCircleFilled, CloseOutlined } from '@ant-design/icons';
class UserTopTab extends React.Component {
render() {
return (
<>
<div className="d-inline-flex" style={{ background: "#242F84", width: "100%", zIndex: "990" }}>
<NavLink to="/" className="Cambium ">
<p className="mb-0 px-2 White" >Title</p>
</NavLink>
<NavLink to="/AllSearches" className='tab my-auto TabStyle'>
<p className="mb-0 FS_20 px-2 White" >All Searches</p>
</NavLink>
<NavLink to="/AllSearches" className='tab my-auto TabStyle'>
<p className="mb-0 FS_20 px-2 White" >Untitled 1</p>
</NavLink>
{this is toogle button when clicked it will open a dialogue box attached to its bottom}
<button type="button" className="mb-0 FS_20 px-2 White" >Open +</button>
{*innerpart of the box*}
<Notification />
<p className="mb-0 Help"><QuestionCircleFilled /></p>
</div>
</>
);
}
}
export default UserTopTab;
//第二节
import React from 'react';
const BelowSection =()=>{
<div>
<h1>bellow Section is displayed here </h1>
</div>
}
export default BelowSection
解决方案
将用于打开框的按钮替换为下面的目标按钮,您可以在打开的对话框中执行任何操作
<div class="dropdown newTab">
<button type="button"
className="mb-0 FS_20 px-2 White Grey border-0 h-100 dropdown-toggle"
id="dropdownMenuButton" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"
style={{ backgroundColor: "#050A30" }} >Open +</button> //target from where you want to place the buton
<div class="dropdown-menu p-0" aria-labelledby="dropdownMenuButton">
Your inner code to be in here that you
need to display in the Drop down Box
</div>
</div>
推荐阅读
- python - 如何在 Keras 中实现 RBF 激活功能?
- sql-server - 缺少 SQL Server 表上的跨服务器查询的行,可能是由于用户权限
- php - 从 PHP 端处理 MySQL 事务:策略和最佳实践
- c# - C#如何使用'await'等待异步客户端套接字的连接
- php - php中基于角色的登录
- google-bigquery - 带有 LIMIT 子句的 Bigquery CASE SENSITIVE 查询不起作用?
- django - Django 测试更新帖子
- typescript - 打字稿通用“演员”功能
- kubernetes - Kubernetes Ingress (GCE) 导致默认服务选择器停止工作
- android - 如何仅通过地址栏中的 URL 打开应用程序