Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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
Html 当对CSS样式表中的图像引用发出http请求时,由什么构成?_Html_Css_Httprequest - Fatal编程技术网

Html 当对CSS样式表中的图像引用发出http请求时,由什么构成?

Html 当对CSS样式表中的图像引用发出http请求时,由什么构成?,html,css,httprequest,Html,Css,Httprequest,如果我有 .myClass1 { background: url(myImage1.jpg) 0px 0px; } .myClass2 { background: url(myImage1.jpg) 0px 10px; } 是否对同一个映像发出了两个http请求? 此外,标记中是否需要有相应的*,以确保发出请求?还是这样做了?*在您最初的问题上有两个不同的图像/URL,所以有两个单独的请求。如果它们是相同的图像,则浏览器缓存将满足第二个请求 关于第二个问题,我刚刚在Chro

如果我有

.myClass1 { 
  background: url(myImage1.jpg) 0px 0px; 
} 

.myClass2 { 
  background: url(myImage1.jpg) 0px 10px; 
}
是否对同一个映像发出了两个http请求?


此外,标记中是否需要有相应的*
,以确保发出请求?还是这样做了?*

在您最初的问题上有两个不同的图像/URL,所以有两个单独的请求。如果它们是相同的图像,则浏览器缓存将满足第二个请求


关于第二个问题,我刚刚在Chrome和Firefox上进行了测试,他们只在有与CSS选择器匹配的元素时才会请求图像。不过,这可能取决于浏览器。

哎呀,它们本来应该是同一个图像!