CSS背景图片不会以短网址显示 [英] CSS background-image won't show with short URL

查看:58
本文介绍了CSS背景图片不会以短网址显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索完了,主题没有帮助.

I've done my searching and the topics haven't been of help.

我正在尝试使标头的背景图片在标头div的X轴上重复.

I'm trying to have the background image of my header repeat across the X axis of the header div.

当我使用长网址(例如,

When I make CSS with a long URL such as

background-image:url('http://site.com/images/logo.png'); 一切正常

当我尝试将CS​​S缩短为〜/images/之类的东西,或者甚至将CSS和站点文件放在根文件夹中并使用/images/时,我一无所获

When I try to shorten the CSS to something such as ~/images/ or even having the CSS and site file already in the root folder and using /images/ I get nothing

background-image:url('~/images/logo.png')

background-image:url('/images/logo.png')

推荐答案

这可能是因为您没有适当缩短URL.

This is possibly because you're not shortening your URLs appropriately.

假定绝对路径为:

url('www.example.com/images/imageName.png');

相对于根的URL为:

url('/images/imageName.png');

相对路径(假设您的CSS文件位于 www.example.com/css/cssStylesheet.css 中)将为:

And a relative path (assuming your CSS file is in www.example.com/css/cssStylesheet.css) would be:

url('../images/imageName.png'); /* parent directory, then the images directory */

为前缀的url格式对我来说是未知的,尽管我怀疑它是ASP或.NET形式?尽管我对此无能为力.

The ~ prefixed url format is unknown to me, though I suspect it's an ASP, or .NET, form? Though I'm unable to advise on that.

可能对您有用的问题:

这篇关于CSS背景图片不会以短网址显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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