简体   繁体   English

背景图片未显示

[英]background image not showing

I have got this html: 我有这个HTML:

<p class="separator" style="background:url('http://localhost:85/WebCamClone/public/images/home/separator.png') repeat-y;"></p>

and this css: 和这个CSS:

    p.separator {
position: absolute;
height: 100%;
width: 10px;
top: 0px;
right: 46px;
z-index: 999;
}

I can see the image when I open it in a new tab, but I cant see the image displayed on the page in p tag..why? 在新标签页中打开图像时可以看到图像,但是在p标签中看不到页面上显示的图像。为什么?

The problem is with your height: 100%; 问题是你的height: 100%; your height can't stretch out as you would expect. 您的身高无法按预期伸展。 to fix this problem you could try following options: 要解决此问题,您可以尝试以下选项:

  1. Give to your height pixel value like with your width 像宽度一样给您的高度像素值

  2. make your html, body { height: 100%; } 使您的html, body { height: 100%; } html, body { height: 100%; } and your height: 100%; html, body { height: 100%; }和您的height: 100%; will work either 将工作

  3. assign position: absolute to your image 分配position: absolute图片position: absolute

You could pick one of them each one should work. 您可以选择其中一个,每个都应该起作用。

maybe the absolute position cause this problem 也许绝对位置会导致此问题

To be sure use a color background , relative position as second step if first not working,third :use 'position : relative' to the parent container 确保首先使用彩色背景,相对位置作为第二步,第三步:使用相对于父容器的“ position:相对”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM