Bootstrap CDN + WP//如何编辑“.css" [英] Bootstrap CDN + WP // How to edit '.css’

查看:46
本文介绍了Bootstrap CDN + WP//如何编辑“.css"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Wordpress + Bootstrap CDN 上构建我的网站.我决定将它放在 CDN 上,以便将来不会出现更新问题,而且我读到这种方式会更快一些.

I’m building my website on Wordpress + Bootstrap CDN. I decided to make it on CDN to have no problem with updates in the future plus I read that this way it’s a bit faster.

所以问题是我的样式有问题.我将我本地的‘style.css’导入到‘header.php’中,但由于来自CDN的‘bootstrap.min.css’也有自己的参数,我无法应用一些东西.

So the thing is I have a problem with styles. I imported my local ‘style.css’ to ‘header.php’, but since ‘bootstrap.min.css’ from CDN also has its own parameters I can’t apply some things.

如何重写CDN的参数?或者有没有办法编辑这个确切的bootstrap.min.css"文件?

How do I rewrite CDN’s parameters? Or is there a way to edit this exact ‘bootstrap.min.css’ file?

提前致谢.

推荐答案

您只需使用 wp_enqueue_style 即可加载这些文件.这是一个您可以从中获得灵感的示例.

You can simply just use wp_enqueue_style to load those files. Here is an example you can get an idea from.

function enqueue_my_scripts() {
wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', array('jquery'), '1.9.1', true); // we need the jquery library for bootsrap js to function
wp_enqueue_script( 'bootstrap-js', '//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js', array('jquery'), true); // all the bootstrap javascript goodness
}
add_action('wp_enqueue_scripts', 'enqueue_my_scripts');


function enqueue_my_styles() {
wp_enqueue_style( 'bootstrap', '//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css' );
wp_enqueue_style( 'my-style', get_template_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'enqueue_my_styles');

要编写规则,只需在 style.css 文件中使用 !important.

and to write the rules just use !important in your style.css file.

当您使用 wp_enqueue_style 时,您可以选择控制样式和脚本用于进一步参考的位置.这是一个如何使用它的示例.

When you use wp_enqueue_style, you have the option to take control on where your styles and script be used for further references. Here is an example how to use it.

function my_enqueue_stuff() {
  if ( is_page( 'landing-page-template-one' ) ) {
    /** Call landing-page-template-one enqueue */
  } else {
    /** Call regular enqueue */
  }
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_stuff' );

这篇关于Bootstrap CDN + WP//如何编辑“.css"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆