简体   繁体   English

如何在图像背景上覆盖文本

[英]how do I overlay text on an image background

Here is my CSS 这是我的CSS

.newbody
{
    background-image:url('Images/CityofChicago.jpg');

    height:600px;
    width:1270px;
    position:relative;

}

.otherstuff
{

     position:absolute;
}

here is my HTML 这是我的HTML

   <div class="newbody">
      <!--  <img src="Images/CityofChicago.jpg" height="600px" width="1280px" class="image" alt=""/> -->
      some Text

      <div class="otherstuff">
      <ul>
        <li>One </li>
        <li>Two </li>
        <li>Three</li>
      </ul>
      </div>
      </div>

Your code looks right, it is just a matter of getting the right path to your image. 您的代码看起来正确,只是获得正确图像路径的问题。 If your css is inline in your html document the location of the html document becomes the base, if your css is in a .css file then its location is the base. 如果css在html文档中是内联的,则html文档的位置将成为基础,如果css在.css文件中,则其位置将为基础。 If your structure is: 如果您的结构是:

  • index.html index.html
    • /css / css
      • style.css style.css
    • /images /图片
      • CityofChicago.jpg CityofChicago.jpg

then the line would be background-image:url('../Images/CityofChicago.jpg'); 那么该行将是background-image:url('../Images/CityofChicago.jpg');

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

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