简体   繁体   English

div背景图片无法在chrome中正确显示

[英]div background image not displaying properly in chrome

I'm helping a designer friend with a problematic page and it's throwing me for a bit of a loop as well. 我正在帮助一个有问题的页面的设计师朋友,这也让我陷入了一个循环。 There should be 4 divs throughout the page with a background image and text. 整个页面上应有4个div,其中包含背景图片和文字。 The page displays as expected in IE and FF but in chrome only the div that's visible on load displays it's background image. 该页面将在IE和FF中按预期显示,但在Chrome中,仅在加载时可见的div会显示其背景图像。 Additionally, the others will display if you highlight the space they should occupy. 此外,如果您突出显示其他人应该占据的空间,其他人也会显示。

I created a scrubbed version of the page as an example: http://furrylogic.net/playground/rose/example.html 我以页面的净化版本为例: http : //furrylogic.net/playground/rose/example.html

Any feedback or suggestions would be greatly appreciated. 任何反馈或建议,将不胜感激。 THANKS! 谢谢!

I think this is going to be down to poor markup. 我认为这将归因于差劲的加价。

Example with your <div id="hope"> : 您的<div id="hope">示例:

Currently 目前

<div id="hope">
    <div class="hinside">
        <center>
           <p></p>
           <h1 style="color: rgb(255, 255, 255); text-transform: uppercase; opacity: 1;" data-    sb="fadeInDown" class="sb-effect-displayed animated fadeInDown">You are Loved!</h1>
           <p>&nbsp;</p>
           <p></p>
        </center>
    </div>
</div>

Could be simplified to: 可以简化为:

HTML 的HTML

<div id="hope" class="banner-image">
    <h1 data-sb="fadeInDown" class="sb-effect-displayed animated fadeInDown">You are Loved!</h1>
</div>

CSS 的CSS

.banner-image {
    width: 100%;
    margin: 20px 0;
    padding: 0;
}
.banner-image h1 {
    text-align: center;
    margin: 80px 0;
    padding: 0;
    text-transform: uppercase;
    color: #fff;
}

This is just to get you on the right track, note I have removed the empty <p> tags and padding from the <h1> . 这只是为了使您走上正确的轨道,请注意,我已经删除了<h1>中空的<p>标记和填充。 I can give a working example if you provide a JsFiddle . 如果您提供JsFiddle,我可以举一个工作的例子。

Remove background-attachment: fixed from all those ids ie #time, #bible, #hand and #hope. 删除背景附件:从所有这些ID(即#time,#bible,#hand和#hope)中修复。 If that doesn't work, just let me know. 如果那不起作用,请告诉我。 :) :)

Change the <h1></h1> tags to <h1><font id="h1"></font></h1> tags with the style or css on #h1 . 使用#h1上的样式或css将<h1></h1>标签更改为<h1><font id="h1"></font></h1>标签。 For some weird reason some browsers don't display p and h1 tags properly which the font tag sometimes eliminates. 由于某些奇怪的原因,某些浏览器无法正确显示p和h1标签,而字体标签有时会消除这些标签。 Also I would suggest using font instead of p to eliminate those line breaks some browsers put in. 我也建议使用字体而不是p来消除某些浏览器中的换行符。

<div>不显示背景图片</div><div id="text_translate"><p>在我的 css 文件中,我有一个名为“homehero”的 id,它显示背景图像。</p><pre class="lang-css prettyprint-override"> #homehero { background-image: url("images/coast.jpg"); background-size: 100% 100%; background-repeat: no-repeat; }</pre><p> 在我的 html 文件中,我有一个 div 使用这个 id 来显示图像; 但是,该图像不会出现。</p><pre class="lang-html prettyprint-override"> <div id="homehero"> <.-- Home Page Image --> <,-- <img src="images/coast.jpg" width="100%" height="100%" alt="A Sunny Coastline"> --> <!-- Old line of html that displayed the same image, but converted to css id. --> </div> <!-- End of Home Page Image --></pre><p> 完整的 html 文件可以在<a href="https://pastebin.com/SJLpQAGY" rel="nofollow noreferrer">这里</a>找到。</p><p> 完整的 css 文件可以在<a href="https://pastebin.com/5Yhw04Tc" rel="nofollow noreferrer">这里</a>找到。</p><p> 编辑:将图像设置为另一个元素的背景图像时显示该图像,仅在此 id 中出现问题。</p></div> - <div> not displaying background image

暂无
暂无

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

相关问题 div的背景图片无法正确显示 - background-image of div not displaying properly Chrome中未显示背景图片 - Background Image not Displaying in Chrome 背景图像未在Div中显示 - Background Image is not displaying in Div <div>不显示背景图片</div><div id="text_translate"><p>在我的 css 文件中,我有一个名为“homehero”的 id,它显示背景图像。</p><pre class="lang-css prettyprint-override"> #homehero { background-image: url("images/coast.jpg"); background-size: 100% 100%; background-repeat: no-repeat; }</pre><p> 在我的 html 文件中,我有一个 div 使用这个 id 来显示图像; 但是,该图像不会出现。</p><pre class="lang-html prettyprint-override"> <div id="homehero"> <.-- Home Page Image --> <,-- <img src="images/coast.jpg" width="100%" height="100%" alt="A Sunny Coastline"> --> <!-- Old line of html that displayed the same image, but converted to css id. --> </div> <!-- End of Home Page Image --></pre><p> 完整的 html 文件可以在<a href="https://pastebin.com/SJLpQAGY" rel="nofollow noreferrer">这里</a>找到。</p><p> 完整的 css 文件可以在<a href="https://pastebin.com/5Yhw04Tc" rel="nofollow noreferrer">这里</a>找到。</p><p> 编辑:将图像设置为另一个元素的背景图像时显示该图像,仅在此 id 中出现问题。</p></div> - <div> not displaying background image 背景图像未显示在 Div 上 - Background Image Not Displaying On Div div背景图片未显示 - Div background image not displaying 背景图片无法在手机上正确显示 - Background image not displaying properly on mobile Chrome和Firefox中未显示背景图片 - Background image not displaying in Chrome and Firefox chrome浏览器中不显示背景图片 - Background image not displaying in chrome browser 背景图片未完整显示 - Background image is not displaying in full Div
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM