2015-03-30 113 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); } 
} 
相關問題