css - 为什么背景图片不显示?

标签 css html bootstrap-4

我的html代码如下所示:

<div class="content-wrapper">
  <div class="center">
    <h1>heading</h1>
  </div>
  <div class="lr">
    <p> paragraph </p>
  </div>
</div>

.css 中的内容包装部分如下:

.content-wrapper{ 
    background-image: url(/picture.jpg);  
    background-position: center center; 
    background-repeat: no-repeat; 
    background-attachment: fixed; 
    background-size: cover;
}

我无法获取文本背后的背景图像。 我不想通过直接正文标签设置背景图像。 我被困在这里了。 请帮忙。 谢谢

最佳答案

这是你所期望的吗? 如果是,那么您的代码似乎没问题。确保您的图片得到良好引用。

.content-wrapper{ 
    background-image: url("http://res.cloudinary.com/sayob/image/upload/v1526907328/483257_vwhhfw.jpg");  
    background-position: center center; 
    background-repeat: no-repeat; 
    background-attachment: fixed; 
    background-size: cover;
}
<div class="content-wrapper">
  <div class="center">
    <h1>heading</h1>
  </div>
  <div class="lr">
    <p> paragraph </p>
  </div>
</div>

关于css - 为什么背景图片不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50569120/

相关文章:

javascript - 我想更改表单控件类类型的日期格式是日期吗?

html - Bootstrap jumbotron 全高没有导航栏的高度

css - 避免重复 CSS 样式?

css - 如何自定义ionic 4侧边菜单?

css - 我可以将我的 CSS 中的 Twitter Bootstrap 脚手架跨度称为 mixin 而不是类吗?

html - 网站视口(viewport)在 Bootstrap 4 上的 Safari 浏览器上仍然可以缩放和捏合

javascript - jQuery - 每当 Div 中的内容增加/减少时调用一个函数

javascript - 无法更改 div 尺寸

javascript - 如何只在子div元素中触发onclick事件,而不在父div元素中触发?

Laravel 8 JetStream Bootstrap 4