简体   繁体   English

CSS image.png未加载到Google驱动器上

[英]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.

相关问题 没有初始src的图片不会显示CSS背景图片:url(“ image.png”); - image without initial src doesn't display css background-image: url(“image.png”); 如何根据用户性别显示两个不同的 image.png? - How to display two different image.png depending on users gender? "GET /media/img/image.png HTTP/1.1" 404 2575 - "GET /media/img/image.png HTTP/1.1" 404 2575 iPhone上的HTML上传(iOS):文件名始终相同(image.jpg,image.png,...) - HTML Upload on iPhone (iOS): filename is always same (image.jpg, image.png, …) 即使使用url('../../ images / image.png'),背景图片路径也不起作用 - Background image path is not working even when I use url('../../images/image.png') UIWebView背景图片:url('image.png')不起作用? - UIWebView Background-Image: url('image.png') doesn't work? 如何在html,css中处理PNG图像加载时间 - How to handle PNG image loading time in html, css Django 放在根文件夹时找不到“/media/image.png” - Django cannot find “/media/image.png” when placed in root folder body {background: url(image.png)} 不会居中或适应导航器大小? - body {background: url(image.png)} won't center or adapt to navigator size? PNG图像的透明度与CSS背景属性重叠 - PNG image's transparency overlaps a CSS background property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM