2015-03-30 97 views
0

我想将徽标放在引导程序导航栏中,但问题是徽标比导航栏大,所以我希望徽标能够响应并且很好地适应导航栏。我已经尝试了所有可以找到的技巧,但仍然很大。请帮 这里是母版页:如何将徽标放在引导程序导航栏中

<body> 
    <!-- Navigation --> 
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 
     <div class="container"> 
      <!-- Brand and toggle get grouped for better mobile display --> 
      <div class="navbar-header"> 
       <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
        <span class="sr-only">Toggle navigation</span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 
       <a class="navbar-brand" href="#"> 
        <%--<img src="http://placehold.it/150x50&text=Logo" alt=""/>--%> 
        <img src="img/chs.jpg"" alt=""/> 
       </a> 
      </div> 
      <!-- Collect the nav links, forms, and other content for toggling --> 
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
       <ul class="nav navbar-nav"> 
        <li> 
         <a href="#">About</a> 
        </li> 
        <li> 
         <a href="#">Services</a> 
        </li> 
        <li> 
         <a href="#">Contact</a> 
        </li> 
       </ul> 
      </div> 
      <!-- /.navbar-collapse --> 
     </div> 
     <!-- /.container --> 
    </nav> 

    <!-- Page Content --> 
    <div class="container"> 
     <div class="row"> 
      <div class="col-lg-12"> 
       <h1>Logo Nav by Start Bootstrap</h1> 
       <p>Note: You may need to adjust some CSS based on the size of your logo. The default logo size is 150x50 pixels.</p> 
      </div> 
     </div> 
    </div> 
    <!-- /.container --> 

    <!-- jQuery --> 

    <script src="Scripts/jquery-2.1.3.js"></script> 
    <!-- Bootstrap Core JavaScript --> 

    <script src="Scripts/bootstrap.min.js"></script> 

</body> 

我的CSS文件

body { 
    padding-top: 70px; /* Required padding for .navbar-fixed-top. Change if height of navigation changes. */ 
} 

.navbar-fixed-top .nav { 
    padding: 15px 0; 
} 

.navbar-fixed-top .navbar-brand { 
    padding: 0 15px; 
} 

@media(min-width:768px) { 
    body { 
     padding-top: 100px; /* Required padding for .navbar-fixed-top. Change if height of navigation changes. */ 
    } 

    .navbar-fixed-top .navbar-brand { 
     padding: 15px 0; 
    } 
} 
+0

http://www.bootply.com/2YrBFFYHn1 bootply没有错,你的图像大小是多少? – Kinburn101 2015-03-30 22:56:06

回答

1

你可以做媒体查询来改变它的大小,例如:

@media(max-width: 768px;) { 
    .navbar-brand img { width: 100px; height: 75px; } 
} 

等等针对您定位的不同尺寸。

此外,您还可以更大胆一点,的,而不是内.navbar-brand<img />标签,您可以设置它的背景是这样的:

.navbar-brand img { width: 200px; height: 125px; background-image: url(../img/my-logo.png); } 

这将允许您更改与媒体查询实际的图像,例如:

@media(max-width: 768px;) { 
    .navbar-brand img { width: 100px; height: 75px; background-image: url(../img/my-logo-small.png); } 
} 
相关问题