我创建了一个创建表单的小部件。我正在使用Twitter引导框架来设计这些表单。我有两个WP实例:
一个是使用Alterna主题,它也使用引导。表单在这个主题上看起来很棒。
另一个使用OptimizerPress,它不使用引导。问题来了。该主题不使用Bootstrap,它们的CSS覆盖了Bootstrap中的定义。
所以我的问题是:
如何使我的小部件CSS比主题CSS具有更高的优先级以下是我如何将CSS添加到我的小部件中:
class LeadCapture_Form_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
\'lc-form-widget\', // Base ID
\'LeadCapture_Form_Widget\', // Name
array( \'description\' => __( \'Widget that outputs a basic form with that will capture the user\\\'s information and submits it to the CRM.\', \'text_domain\' ), ) // Args
);
add_action( \'wp_enqueue_scripts\', array( $this, \'register_plugin_styles\' ) );
}
/**
* Register and enqueue style sheet.
*/
public function register_plugin_styles() {
wp_register_style( \'lc-form-widget\', plugins_url( \'LeadCapture_Form_Widget/css/form.css\' ) );
wp_enqueue_style( \'lc-form-widget\' );
}