Bootstrap下拉菜单溢出html正文

时间:2017-12-21 04:31:41

标签: html css twitter-bootstrap

我有一个导航栏和一个下拉菜单,我的问题是下拉菜单溢出身体(见下图)。我搜索了https://getbootstrap.com/docs/4.0/components/dropdowns/中的所有下拉示例,但我找不到任何示例。我该如何解决?

谢谢你的帮助!

the dropdown menu where i mark by the red rectangular

这是我的代码,我已经实现了所有必需的Bootstrap

<!DOCTYPE html>
<html>
<head>
    <title>Login page</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
          integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
            integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
            crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"
            integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"
            crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
            integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
            crossorigin="anonymous"></script>
    <style>
        table {
            margin-top: 40px;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#">User Management</a>
    <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link" href="#">Home</a>
            </li>
        </ul>
        <span class="navbar-text">
         <div class="btn-group">
  <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
          aria-expanded="false">
         button
  </button>
  <div class="dropdown-menu">
     <a class="dropdown-item" href="#">View Account</a>
    <a class="dropdown-item" href="#">Sign out</a>
  </div>
</div>
    </span>
    </div>
</nav>
</body>
</html>

2 个答案:

答案 0 :(得分:3)

您可以将<img src ='http://www.example.com/xxx.png'> 替换为left:0;

中的right:0px

&#13;
&#13;
.dropdown-menu
&#13;
table {
  margin-top: 40px;
}
.dropdown-menu {
  left:inherit !important;
  right:0px;
}
&#13;
&#13;
&#13;

答案 1 :(得分:0)

pd.read_csv(file_name,dtype={col1:type}))