2013-10-29 61 views
0

我已經將bootstrap添加到了我的管理頁面,並且隨處可見。我該如何解決這個問題? 我在wordpress.stackexchange.com上提過,他們建議我在這裏提問。我一直在搜索,但我沒有得到具體的答案。 我無法添加屏幕截圖。 你可以在 wordpress stackexchangeBootstrap覆蓋WordPress的默認行爲

add_action('admin_enqueue_scripts', 'scripts_for_admin_page'); 

訪問截屏,然後註冊並排隊

+1

究竟是什麼被覆蓋誰? –

+0

在發佈OP鏈接後,Bootstrap在他的WordPress安裝中重寫了CSS。 –

回答

0

你的問題是CSS相關。您正在加載Bootstrap的CSS在您的WordPress主題之上,這是重寫其他元素並導致不期望的結果,這是預期的。

Bootstrap的CSS包含頂級DOM元素的樣式,因此您會看到覆蓋問題。 Bootstrap CSS source

你需要弄清楚哪些CSS元素是你需要的Bootstrap並且將它們定位到你的WordPress插件只有。考慮引導文件中,以下變化:

引導CSS:

h1, 
h2, 
h3, 
h4, 
h5, 
h6 { 
    margin: 10px 0; 
    font-family: inherit; 
    font-weight: bold; 
    line-height: 20px; 
    color: inherit; 
    text-rendering: optimizelegibility; 
} 

你的插件CSS:

#myPlugin h1, 
#myPlugin h2, 
#myPlugin h3, 
#myPlugin h4, 
#myPlugin h5, 
#myPlugin h6 { 
    margin: 15px 0; 
    font-family: inherit; 
    font-weight: bold; 
    line-height: 20px; 
    color: inherit; 
    text-rendering: optimizelegibility; 
} 

此外,作爲另一個想法。在你的WordPress管理頁面,而不是,:

add_action('admin_enqueue_scripts', 'scripts_for_admin_page'); 

你應該考慮

<?php include_once(ABSPATH . 'wp-admin/includes/plugin.php'); ?> <?php is_plugin_active($plugin) ?> 

法典參考插件激活:http://codex.wordpress.org/Function_Reference/is_plugin_active

至於別人已經指出我們在另一個線程,這其實就是直到CSS開發和開發WordPress插件的最佳實踐。

+0

謝謝你的幫助。 –

+0

不客氣。 –