[英]CSS image.png's not loading on google drive
I am trying to get my css file using background: url(); 我正在尝试使用背景获取我的css文件:url(); to use the correct path to display my images on my index.html, this webpage is a 1 page index.html which just displays static content and some images, nothing fancy, I currently have it on google drive being hosted perfectly fine.
为了使用正确的路径在我的index.html上显示我的图像,此网页是1页的index.html,它仅显示静态内容和一些图像,没有什么花哨的东西,我目前在google驱动器上托管得非常好。
It's just the image paths are not working when they are set to relative which would be "img/example.png" and they don't work with the link you get from setting the images to public so they can be viewed by anyone which for example would be " https://drive.google.com/file/d/IMAGE_CODE/view?usp=sharing " 只是将图像路径设置为相对路径时它们将不起作用,即为“ img / example.png”,并且它们与您将图像设置为公开状态所获得的链接不起作用,因此任何人都可以查看它们例如“ https://drive.google.com/file/d/IMAGE_CODE/view?usp=sharing ”
How have you managed to get your images to load on drive using CSS background: url();? 如何使用CSS背景url();设法将图像加载到驱动器上?
I don't want a direct sort of link so every time my website refreshes it has to re download the images, that creates very slow refresh page loading, I want it to look for them just like a relative path with much faster loading. 我不需要直接的链接,因此每次我的网站刷新时都必须重新下载图像,这会导致刷新页面加载非常缓慢,我希望它像加载速度更快的相对路径一样查找它们。
You may have an issue with your path being in the wrong directory, so you would use 您的路径可能位于错误的目录中,可能会出现问题,因此您可以使用
../
to move up a directory until the correct one is reached. 向上移动目录,直到找到正确的目录为止。 For example, if your css file is located in a folder structure such as "root/assets/stylesheets/style.css" and your image is at "root/img/image.png" then within your css file, you would have to use the following code
例如,如果您的css文件位于文件夹结构(例如“ root / assets / stylesheets / style.css”)中,并且图像位于“ root / img / image.png”中,则必须在css文件中使用以下代码
background-image: url('../../img/image.png');
to move up two directories to properly call your image. 向上移动两个目录以正确调用您的图片。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.