2016-09-14 95 views
-1

我想更改bootstrap分頁顏色,但我不能以任何方式進行,無論我做什麼,它都是藍色。我希望將.pagination li a.active更改爲紅色,將.pagination li a更改爲黑色。我做錯了什麼?無法更改Bootstrap分頁顏色

<!DOCTYPE html> 
<html lang="pt-br"> 
<head> 
    <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" <link rel="stylesheet" href="http://path/to/font-awesome/css/font-awesome.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
    <style> 
    .pagination ul { 
    display: inline-block; 
    padding: 0; 
    margin: 0; 
    } 
    .pagination li { 
    display: inline; 
    } 
    .pagination li a { 
    color: black; 
    float: left; 
    padding: 8px 16px; 
    text-decoration: none; 
    } 
    .pagination li a.active { 
    background-color: red; 
    color: white; 
    } 
    .pagination li a:hover:not(.active) { 
    background-color: #ddd; 
    } 
    </style> 
</head> 

<body> 
    <div class="container text-center"> 
    <ul class="pagination"> 
     <li><a href="#">«</a> 
     </li> 
     <li><a href="#">1</a> 
     </li> 
     <li class="active"><a href="#">2</a> 
     </li> 
     <li><a href="#">3</a> 
     </li> 
     <li><a href="#">4</a> 
     </li> 
     <li><a href="#">5</a> 
     </li> 
     <li><a href="#">»</a> 
     </li> 
    </ul> 
    </div> *emphasized text*</div> 
</body> 

</html> 
+0

工作例如,你可以使用!重要的,或者你可以只添加你的外部CSS文件引導css文件後重寫引導CSS – Keith

回答

0

在每個覆蓋的css聲明之後使用「!important」! 例如:

.pagination li {display: inline !important;} 
3

您沒有任何<a>標籤與active類,所以你需要改變兩個東西

  1. .pagination li a.active應改爲 .pagination li.active a
  2. .pagination li a:hover:not(.active)應改爲.pagination li:hover:not(.active) a

見下文

<link rel="stylesheet" href="http://path/to/font-awesome/css/font-awesome.min.css"> 
 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 

 
.pagination ul { 
 
    display: inline-block; 
 
    padding: 0; 
 
    margin: 0; 
 
} 
 

 
.pagination li { 
 
    display: inline; 
 
} 
 

 
.pagination li a { 
 
    color: black; 
 
    float: left; 
 
    padding: 8px 16px; 
 
    text-decoration: none; 
 
} 
 

 
.pagination li.active a { 
 
    background-color: red; 
 
    color: white; 
 
} 
 

 
.pagination li:hover:not(.active) a { 
 
    background-color: #ddd; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 

 

 
<div class="container text-center"> 
 
    <ul class="pagination"> 
 
    <li><a href="#">«</a></li> 
 
    <li><a href="#">1</a></li> 
 
    <li class="active"><a href="#">2</a></li> 
 
    <li><a href="#">3</a></li> 
 
    <li><a href="#">4</a></li> 
 
    <li><a href="#">5</a></li> 
 
    <li><a href="#">»</a></li> 
 
    </ul> 
 
</div> 
 
<div>*emphasized text*</div>

+0

謝謝。我不知道爲什麼,但它只適用於外部的CSS文件 –