导航栏的所有项目都显示在页面的左侧

时间:2019-09-27 05:54:47

标签: jquery html css

 <header>
    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark navbar-change" id="main_navbar">
        <a class="navbar-brand" href="index.html">
            <img class="logoHeadstart-responsive" src="images/Logo_web_h59px.png" alt="Headstart Malaysia">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse rounded" id="navbarCollapse">
            <ul class="navbar-nav ml-auto" id="menu">
                <li class="nav-item active">
                    <a class="nav-link" href="index.html">Home<span class="sr-only">(current)</span></a>
                </li>
               <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='aboutUs.html'">About</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="aboutUs.html#aboutUs-anchor">Overview</a>
                        <li><a href="#">Facilities</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="aboutUs.html#facilities-anchor">Academy@SACC</a></li>
                                <li><a href="#">Therapy@Damansara</a></li>
                            </ul>
                        </li>
                        <li><a href="#">Team</a>

                        </li>
                    </ul>
                </li>


                <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='#'">Intervention</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="eip.html#overview-anchor" class="eip-text"><span>Early Intervention</span></a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="eip.html#overview-anchor">Overview</a></li>
                                <li><a href="eip.html#admission-anchor">Admission</a></li>
                                <li><a href="eip.html#calendar-anchor">Timetable</a></li>
                                <li><a href="eip.html#academic-calendar-anchor">Calendar</a></li>
                            </ul>
                        </li>
                        <!--<li><a href="#">Junior <span style="background-color: #F18805" class="badge badge-secondary animated pulse">COMING SOON</span></a>-->
                        <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                            <li><a href="#">Overview</a></li>
                            <li><a href="#">Admission</a></li>
                            <li><a href="#">Timetable</a></li>
                            <li><a href="#">Calendar</a></li>
                        </ul>
                        </li>
                        <li><a href="eip.html#devmilestones-anchor">Developmental Milestones</a>

                    </ul>
                </li>

                <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='therapy.html'">Therapy</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="therapy.html">Academy@SACC Mall</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="therapy.html">Behaviour</a></li>
                                <li><a href="therapy.html">Speech</a></li>
                                <li><a href="therapy.html">Occupational</a></li>

                            </ul>
                        </li>
                        <li><a href="therapy.html">Therapy@Damansara</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="therapy.html">Speech</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>


                <li class="nav-item navbar-fixed-top"><div class="dropdown">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='eca.html'">ECA</button>
                    <div class="dropdown-content rounded">
                        <a href="eca.html#eca-anchor">Overview</a>
                        <a href="eca.html#classes-anchor">Classes</a>
                        <a href="eca.html#eca-timetable-anchor">Timetable</a>

                    </div>
                </div>
                </li>             
                </div>
                </li>


            </ul>

        </div>
    </nav>
</header>

我正在为公司网站创建一个页面。因此,我必须使用与网站中相同的标题。但是,当我粘贴它时,它显示在页面的左侧。

以前,我曾尝试过具有分页编码的页面的其他版本,但它确实有效。但是,当我尝试具有可折叠帖子功能的版本时,它无法正常工作。

导航栏应为水平且具有下拉功能。但它似乎粘在页面的左侧

我对本页面非常陌生,基本上是Web开发人员。

It should appear like this. A normal looking horizontal navbar Unfortunately, it appears like this.

1 个答案:

答案 0 :(得分:0)

您需要在HTML文件中安装引导程序或将其链接:

在您的头部标签中:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

在您的身体标签中(最好在结尾标签之前,在结束标签之前):

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

See the example here我只是通过CodePen链接到引导CDN,它起作用了,我没有更改您提供的代码中的任何内容

<header>
    <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark navbar-change" id="main_navbar">
        <a class="navbar-brand" href="index.html">
            <img class="logoHeadstart-responsive" src="images/Logo_web_h59px.png" alt="Headstart Malaysia">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse rounded" id="navbarCollapse">
            <ul class="navbar-nav ml-auto" id="menu">
                <li class="nav-item active">
                    <a class="nav-link" href="index.html">Home<span class="sr-only">(current)</span></a>
                </li>
               <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='aboutUs.html'">About</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="aboutUs.html#aboutUs-anchor">Overview</a>
                        <li><a href="#">Facilities</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="aboutUs.html#facilities-anchor">Academy@SACC</a></li>
                                <li><a href="#">Therapy@Damansara</a></li>
                            </ul>
                        </li>
                        <li><a href="#">Team</a>

                        </li>
                    </ul>
                </li>


                <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='#'">Intervention</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="eip.html#overview-anchor" class="eip-text"><span>Early Intervention</span></a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="eip.html#overview-anchor">Overview</a></li>
                                <li><a href="eip.html#admission-anchor">Admission</a></li>
                                <li><a href="eip.html#calendar-anchor">Timetable</a></li>
                                <li><a href="eip.html#academic-calendar-anchor">Calendar</a></li>
                            </ul>
                        </li>
                        <!--<li><a href="#">Junior <span style="background-color: #F18805" class="badge badge-secondary animated pulse">COMING SOON</span></a>-->
                        <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                            <li><a href="#">Overview</a></li>
                            <li><a href="#">Admission</a></li>
                            <li><a href="#">Timetable</a></li>
                            <li><a href="#">Calendar</a></li>
                        </ul>
                        </li>
                        <li><a href="eip.html#devmilestones-anchor">Developmental Milestones</a>

                    </ul>
                </li>

                <li class="nav-item navbar-fixed-top">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='therapy.html'">Therapy</button>
                    <ul style="list-style-type: none; margin: 0; padding: 0;" class="dropdown-content rounded">
                        <li><a href="therapy.html">Academy@SACC Mall</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="therapy.html">Behaviour</a></li>
                                <li><a href="therapy.html">Speech</a></li>
                                <li><a href="therapy.html">Occupational</a></li>

                            </ul>
                        </li>
                        <li><a href="therapy.html">Therapy@Damansara</a>
                            <ul style="list-style-type: none; margin: 0; padding: 0; margin-left: 30px" class="dropdown-content rounded">
                                <li><a href="therapy.html">Speech</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>


                <li class="nav-item navbar-fixed-top"><div class="dropdown">
                    <button style="color: #0756a5" class="nav-link dropbtn" onclick="location.href='eca.html'">ECA</button>
                    <div class="dropdown-content rounded">
                        <a href="eca.html#eca-anchor">Overview</a>
                        <a href="eca.html#classes-anchor">Classes</a>
                        <a href="eca.html#eca-timetable-anchor">Timetable</a>

                    </div>
                </div>
                </li>             
                </div>
                </li>


            </ul>

        </div>
    </nav>
</header>