如何覆蓋引導CSS樣式?我需要修改bootstrap.css適合我的網站。我覺得最好是分開custom.css文件而不是修改bootstrap.css直接原因之一是bootstrap.css得到一個更新,我將痛苦嘗試重新-包括我的所有修改。我會為這些樣式犧牲一些加載時間,但對于我要覆蓋的少數樣式來說,這是可以忽略不計的。我要重寫嗎bootstrap.css所以我移除錨/類的風格?例如,如果我想刪除legend:legend {
display: block;
width: 100%;
padding: 0;
margin-bottom: 20px;
font-size: 21px;
line-height: inherit;
color: #333333;
border: 0;
border-bottom: 1px solid #e5e5e5;}我可以刪除所有這些bootstrap.css但是,如果我對覆蓋CSS的最佳實踐的理解是正確的,那么我應該做什么呢?為了清楚起見,我想刪除所有的圖例樣式,并使用父級的CSS值。那么,結合Pranav的回答,我會做以下工作嗎?legend {
display: inherit !important;
width: inherit !important;
padding: inherit !important;
margin-bottom: inherit !important;
font-size: inherit !important;
line-height: inherit !important;
color: inherit !important;
border: inherit !important;
border-bottom: inherit !important;}(我希望有一種方法可以這樣做:)legend {
clear: all;}
3 回答

catspeake
TA貢獻1111條經驗 獲得超0個贊
!important
身份證100分 類和偽類10分 標記選擇器和偽元素的1點 注意:如果元素具有內聯樣式 (1000點)
<body id="bootstrap-overrides">
/* Example selector defined in Bootstrap */.jumbotron h1 { /* 10+1=11 priority scores */ line-height: 1; color: inherit;}/* Your initial take at styling */h1 { /* 1 priority score, not enough to override Bootstrap jumbotron definition */ line-height: 1; color: inherit;}/* New way of prioritization */#bootstrap-overrides h1 { /* 100+1=101 priority score, yay! */ line-height: 1; color: inherit;}

元芳怎么了
TA貢獻1798條經驗 獲得超7個贊
始終在基本CSS文件之后加載自定義CSS(不響應)。 避免使用 !important
如果可能的話。它可以覆蓋基本CSS文件中的一些重要樣式。 如果不想丟失媒體查詢,請始終在custom.css之后加載引導-responsive.css。-必須跟隨 更喜歡修改所需的屬性(不是全部)。
- 3 回答
- 0 關注
- 876 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消