简体   繁体   English

如何使文字显示在背景图片上

[英]How can I get text to appear OVER the background image

I have successfully set a photograph as the background to my website and got it to fill the page so it is fixed and not tiled. 我已经成功地将一张照片设置为我的网站的背景,并使其充满了页面,因此它是固定的而不是平铺的。 Now I want the navigation bar to appear in the center of the image. 现在,我希望导航栏出现在图像的中央。 However, the navigation bar is still hidden behind the background image despite the fact that I have set the image quality as "background". 但是,尽管我将图像质量设置为“背景”,但导航栏仍隐藏在背景图像后面。 How can I make it appear in the center of the image. 如何使它出现在图像的中央。 Here is the coding I am using for the image: 这是我用于图像的编码:

<div>
<table cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <img id="backgroundimage" src="websitebackground.jpg" />
        </td>
    </tr>
</table>
</div>
<style>
body, html { margin:0; padding:0; height:100%; }
#backgroundimage { position:fixed; left:0; top:0; z-index:1; height:100%; width:100%; }
</style>

dont use tables unless you are displaying tabular data. 除非要显示表格数据,否则不要使用表。 Instead do something like this 而是做这样的事情

HTML 的HTML

<div id="backgroundimage">
    //header content goes in here
</div>

CSS 的CSS

#backgroundimage{
    background-image: url("path-to-image");
    //other styles here
}

You haven't sourced the image correctly, you haven't sourced it as a background image use 您尚未正确来源图片,尚未将其来源用作背景图片

<body background="websitebackground.jpg" id="backgroundimage">

That should put the image in the background behind the text. 那应该将图像放在文本后面的背景中。

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

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