css 如何使用SVG(可缩放矢量图形)作为您的徽标

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 如何使用SVG(可缩放矢量图形)作为您的徽标相关的知识,希望对你有一定的参考价值。

// https://wpsites.net/wordpress-tips/how-to-use-a-svg-scalable-vector-graphic-as-your-logo/
// METHOD 1
// Add the following PHP code to your child themes functions file and your logo.svg file to your images folder:

add_filter( 'theme_mod_header_image', 'filter_header_image', 10, 1 );
function filter_header_image( $url ) {
	
    $url = sprintf( '%s/images/logo.svg', get_stylesheet_directory_uri() ); 
		
    return $url;
}
// METHOD 2
// Add support for a custom header image in your functions file which enables you to add/remove/change your logo in the WordPress customizer. Your themes functions file may already include this code.

add_theme_support( 'custom-header', array(
	'width'           => 300,
	'height'          => 80,
	'header-selector' => '.site-title a',
	'header-text'     => false,
	'flex-height'     => true,
) );

// Then register a default header using this code:

register_default_headers( array(
    'child' => array(
	'url' => '%2$s/images/logo.svg',
	'thumbnail_url' => '%2$s/images/logo.svg',
	'description'   => __( 'SVG Logo', 'genesis' )
) ) );

// Alternatively, you could also register a default header using code like this:

register_default_headers( array(
        'svg-logo' => array(
        'url'   => get_stylesheet_directory_uri() . '/images/logo.svg',
        'thumbnail_url' => get_stylesheet_directory_uri() . '/images/logo.svg',
        'description'   => __( 'SVG Logo', 'genesis' )
)));

// The above code adds a suggested image to the customizer like you see in the following image:
/*-- Method 3 --*/

Simple CSS will also work. Add your logo.svg to your child theme’s images folder.

.header-image .site-title > a {
    background: url(images/logo.svg);
    background-repeat: no-repeat;
}

以上是关于css 如何使用SVG(可缩放矢量图形)作为您的徽标的主要内容,如果未能解决你的问题,请参考以下文章

SVG(可缩放矢量图形)

SVG可缩放矢量图形

svg --- 可缩放矢量图形

SVG(可缩放矢量图形)基本图形绘制方法与path路径命令

Andrid5.0新特性——SVG(可缩放矢量图形)

svg简介与使用