Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css SVG作为背景图像_Css_Svg_Background - Fatal编程技术网

Css SVG作为背景图像

Css SVG作为背景图像,css,svg,background,Css,Svg,Background,我正在将Illustrator中的矢量(徽标)导出为SVG(1.1) 矢量没有渐变或透明度 当我在CSS中使用SVG作为背景图像时 没有显示任何内容,但当我访问图像链接()时,它会完美地显示图像 CSS #site-header { margin: 0; padding: 0; display: block; width: 100%; height: 62px; top: 0; left: 0; position: fixed;

我正在将Illustrator中的矢量(徽标)导出为SVG(1.1) 矢量没有渐变或透明度

当我在CSS中使用SVG作为背景图像时 没有显示任何内容,但当我访问图像链接()时,它会完美地显示图像

CSS

#site-header {
    margin: 0;
    padding: 0;
    display: block;
    width: 100%;
    height: 62px;
    top: 0;
    left: 0;
    position: fixed;
    z-index: 2000;
    border: 0;
    outline: 0;
    font-size: 100%;
    vertical-align: baseline;
    overflow: hidden;
    background-color: #758391;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
    -webkit-box-shadow: 0 0 2px rgba(6, 8, 8, 0.15);
    box-shadow: 0 0 2px rgba(6, 8, 8, 0.15);
}

#site-header #logo {
    display: inline-block;
    float: none;
    width: 10%;
    min-width: 48px;
    height: 100%;
    max-height: 40px;
    margin: 12px 0;
    vertical-align: middle;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

#site-header #logo a {
    width: 100%;
    height: 100%;
    display: block;
    background: rgba(0, 0, 0, 0) url("img/logo.svg") no-repeat center center;
}
HTML

<header id="site-header">
    <hgroup id="logo">
        <a href="#">
            <h1>
                <span class="hide">some hidden content</span>
            </h1>
        </a>
    </hgroup>
</header>

顺便说一下,当我尝试在img元素中使用svg时,它不起作用

知道为什么在使用css作为背景时不显示SVG吗

谢谢

好的,我找到问题了。 这是关于服务器的,我只是在.htaccess中添加了SVG支持

AddType image/svg+xml svg
AddType image/svg+xml svgz

谢谢你

你能添加你的
html/css
细节吗?实际上,我遵循了这个教程,当我使用不同于Web的SVG时,它是有效的,所以我想这是一个导出问题,请确保相对文件路径是正确的。例如,如果您的
css/
文件夹位于
img/
旁边,那么您需要通过
进入路径。i、 e.使用
。/img/logo.svg