2017-03-22 108 views
0

剛開始使用bootstrap,我遇到了一些問題。我想編輯站點的某些部分的大小,但不能讓他們改變/擔心響應性。例如,在下面的代碼中,我想更改圖標的大小,所以我添加了一個額外的類「大小」,並將寬度設置爲300px,但該更改不是在網站上進行的。我甚至嘗試過使用!重要但沒有成功。另外,我想以同樣的方式改變大臂的高度,但一直不成功。我將如何去改變這些?我是否需要進入引導腳本?另外,當設計一個響應式網站時,我應該使用百分比而不是像素?謝謝你,代碼是在這裏:Bootstrap CSS自定義問題

*{ 
    margin: 0; 
    padding: 0; 
} 

.navbar-default{ 
    background-color: rgb(66, 134, 244); 
} 
.under { 
    border-bottom: 15px solid rgb(66, 134, 244); 
} 
.size { 
    width: 300px!important; 
} 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <title>Bootstrap Case</title> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
    <<link rel="stylesheet" type="text/css" href="style.css"> 
</head> 
<body> 

<nav class="navbar navbar-default navbar-fixed-top"> 
    <div class="container-fluid"> 
    <div class="navbar-header"> 

<!-- Button nav for small screens --> 

    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> 
     <span class="icon-bar"></span> 
     <span class="icon-bar"></span> 
     <span class="icon-bar"></span>       
     </button> 
<!-- Brand name --> 

     <a class="navbar-brand" href="#">WebSiteName</a> 
    </div> 

<!-- Makes nav not expand on resize --> 

    <div class="collapse navbar-collapse" id="myNavbar"> 

<!-- Menu --> 
    <ul class="nav navbar-nav"> 
     <li class="active"><a href="#">Home</a></li> 

<!-- Dropdown menu --> 
     <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a> 
     <ul class="dropdown-menu"> 
      <li><a href="#">Page 1-1</a></li> 
      <li><a href="#">Page 1-2</a></li> 
      <li><a href="#">Page 1-3</a></li> 
     </ul> 
     </li> 
<!-- Non dropdown --> 
     <li><a href="#">Page 2</a></li> 
     <li><a href="#">Page 3</a></li> 
    </ul> 
    </div> 
    </div> 
</nav> 
     <div class="jumbotron text-center under"> 
    <h1>Website Heading</h1> 
     <p>Information about the website!</p> 
    </div> 
    <div class="container"> 
     <div class="row"> 
      <div class="col-sm-4 text-center"> 
       <h2>Text</h2> 
       <p>More text describing the heading!</p> 
       <span id="size" class="glyphicon glyphicon-leaf size"></span> 

      </div> 
        <div class="col-sm-4 text-center"> 
       <h2>Text</h2> 
       <p>More text describing the heading!</p> 
       <span class="glyphicon glyphicon-hourglass btn-lg"></span> 

      </div> 

      <div class="col-sm-4 text-center"> 
       <h2>Text</h2> 
       <p>More text describing the heading!</p> 
       <span class="glyphicon glyphicon-plus btn-lg"></span> 
      </div> 

     </div> 

    </div> 
</body> 
</html> 

回答

1

變化的styles.css到custom.css並把它放在文件夾,名爲CSS

<!-- Custom CSS: You can use this stylesheet to override any Bootstrap styles and/or apply your own styles --> 
<link href="css/custom.css" rel="stylesheet"> 
+0

這是行得通,謝謝!我使用像素來設置.jumbotron的高度,但在調整它的大小時保持不變。如何改變尺寸但保持設計的響應? – natem1270

+0

jumbotron只是文本?我的代碼中沒有看到任何jumbotron css – mlegg

1

你可以只包住圖標跨度用h1標籤。 <h1> <span id="size" class="glyphicon glyphicon-leaf size large"> </span></h1>

-1

我想你可以創建一些代碼自定義CSS,所以你不能改變CSS響應

<link rel="stylesheet" type="text/css" href="custom.css"> 

或者你可以,編輯在文件引導CSS

1

我已經做了一些改變你的代碼:

/* 
 
     Put this content into style.css 
 
*/ 
 

 
* { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 

 
.navbar-default { 
 
    background-color: rgb(66, 134, 244); 
 
} 
 

 
.jumbotron { 
 
    /* jumbotron height */ 
 
    height: 400px; 
 
} 
 

 
.under { 
 
    border-bottom: 15px solid rgb(66, 134, 244); 
 
} 
 

 
.size { 
 
    /*use font-size instead of width*/ 
 
    font-size: 100px !important; 
 
    
 
    /* this is the last one: 
 
    width: 300px!important; 
 
    (missing space before !important) 
 
    */ 
 
}
<!-- 
 
    http://stackoverflow.com/questions/42940712/bootstrap-css-customization-issues 
 
--> 
 

 

 
<!DOCTYPE html> 
 
<html lang="en"> 
 

 
<head> 
 
    <title>Bootstrap Case</title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
    <link rel="stylesheet" type="text/css" href="style.css"> 
 

 

 

 

 
</head> 
 

 
<body> 
 

 
    <nav class="navbar navbar-default navbar-fixed-top"> 
 
    <div class="container-fluid"> 
 
     <div class="navbar-header"> 
 

 
     <!-- Button nav for small screens --> 
 

 
     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> 
 
     <span class="icon-bar"></span> 
 
     <span class="icon-bar"></span> 
 
     <span class="icon-bar"></span>       
 
     </button> 
 
     <!-- Brand name --> 
 

 
     <a class="navbar-brand" href="#">WebSiteName</a> 
 
     </div> 
 

 
     <!-- Makes nav not expand on resize --> 
 

 
     <div class="collapse navbar-collapse" id="myNavbar"> 
 

 
     <!-- Menu --> 
 
     <ul class="nav navbar-nav"> 
 
      <li class="active"><a href="#">Home</a></li> 
 

 
      <!-- Dropdown menu --> 
 
      <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a> 
 
      <ul class="dropdown-menu"> 
 
       <li><a href="#">Page 1-1</a></li> 
 
       <li><a href="#">Page 1-2</a></li> 
 
       <li><a href="#">Page 1-3</a></li> 
 
      </ul> 
 
      </li> 
 
      <!-- Non dropdown --> 
 
      <li><a href="#">Page 2</a></li> 
 
      <li><a href="#">Page 3</a></li> 
 
     </ul> 
 
     </div> 
 
    </div> 
 
    </nav> 
 
    <div class="jumbotron text-center under"> 
 
    <h1>Website Heading</h1> 
 
    <p>Information about the website!</p> 
 
    </div> 
 
    <div class="container"> 
 
    <div class="row"> 
 
     <div class="col-sm-4 text-center"> 
 
     <h2>Text</h2> 
 
     <p>More text describing the heading!</p> 
 
     <span id="size" class="glyphicon glyphicon-leaf size"></span> 
 

 
     </div> 
 
     <div class="col-sm-4 text-center"> 
 
     <h2>Text</h2> 
 
     <p>More text describing the heading!</p> 
 
     <span class="glyphicon glyphicon-hourglass btn-lg"></span> 
 

 
     </div> 
 

 
     <div class="col-sm-4 text-center"> 
 
     <h2>Text</h2> 
 
     <p>More text describing the heading!</p> 
 
     <span class="glyphicon glyphicon-plus btn-lg"></span> 
 
     </div> 
 

 
    </div> 
 

 
    </div> 
 
</body> 
 

 
</html>