简体   繁体   English

Bootstrap 3 Navbar元素未正确对齐

[英]Bootstrap 3 Navbar elements not aligned properly

The elements are aligned properly when I run my website locally . 当我在本地运行网站时,元素正确对齐。 This is the expected result: 这是预期的结果:



However, On my Webpage , the elements are aligned to the left. 但是,在“我的网页”上 ,元素向左对齐。

I've tried this but it's still the same. 我已经尝试过了,但是还是一样。 What I don't understand is why is it working on my local machine and not on the server? 我不明白的是为什么它在我的本地计算机上而不在服务器上工作? How do I fix this? 我该如何解决?

Related HTML code : 相关的HTML代码:

<section id="header" class="appear">
    <div class="navbar navbar-fixed-top" role="navigation" data-0="line-height:100px; height:100px; background-color:rgba(0,0,0,0.3);" data-300="line-height:60px; height:60px; background-color:rgba(0,0,0,1);">
         <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="fa fa-bars color-white"></span>
                </button>
                <h1><a class="navbar-brand" href="index.html" data-0="line-height:90px;" data-300="line-height:50px;" style="font-family: 'Cuprum', sans-serif;">           Kaushaya </a>
                </h1>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav right-to-left" data-0="margin-top:20px;" data-300="margin-top:5px;">
                    <li class="active"><a href="index.html">Home</a></li>
                    <li><a href="#section-about" >About</a></li>
                    <li><a href="#testimonials">Work</a></li>
                    <li><a href="#section-skills">Skills</a></li>
                    <li><a href="#section-contact">Contact</a></li>
                    <li><a target="_blank" href="http://www.webparadiso.wordpress.com">Blog</a></li>

                </ul>
            </div><!--/.navbar-collapse -->
        </div>
    </div>
    </section>

Try to use float: right; 尝试使用float: right; on both .nav and .navbar . .nav.navbar

For additional adjusting on a vertical basis, you can use clear: both; 要进行垂直的其他调整,可以使用clear: both; on .nav . .nav If it still does nothing, add !important at the end of the float statement. 如果仍然不执行任何操作,请在float语句的末尾添加!important A Simple CSS solution for your problem! 一个简单的CSS解决方案来解决您的问题!

Hope this helps! 希望这可以帮助!

You could just use twitter bootstraps nav classes to pull it to the right. 您可以只使用twitter bootstraps导航类将其拉到右侧。

<ul class="nav navbar-nav navbar-right">

You can see the example on the bootstrap site http://getbootstrap.com/components/#navbar-default 您可以在引导站点http://getbootstrap.com/components/#navbar-default上看到示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM