html - 带有图像的单个 emcompassing Overflow DIV

标签 html css less

我试图让我的图像在溢出 div 的同时全屏显示

摘自这里: CSS - how to overflow from div to full width of screen

除了不使用颜色,我使用的是图像..但我也希望它是全屏的。有什么想法吗?

.main-header:after {
  content: "";
  position: absolute;
  height: 100%;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 99vw;
  background-size: cover;
  background: url(header_bg.jpg) no-repeat center center; /* help */
  z-index: -1;
}

最佳答案

像这样?

body{
  margin:auto;
}

#for_real,#top{
  width:100px;
  height:100px;
  border:solid;
  z-index:100;
}
#for_real img{
  position:fixed;
  top:0px;
  left:0px;
  opacity:0.5;
  
  width:100vw ;
  height:100vh;
}
<div id='top'>
TOP DIV WITH NO IMAGE
</div>

<div id='for_real'>
DIV WITH IMAGE
<img src='https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT-gpy8G_VpoocZD5L5tuNO_hO_BC9zXl32WCjaHcE-ICiWhL5O'>

</div>

关于html - 带有图像的单个 emcompassing Overflow DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34728727/

相关文章:

javascript - 如何通过 AngularJS 从选择元素中获取对象

css - less css 中某个值的百分比

css - 在 Squarespace 中访问 tweek.less 值

css - 如何将范围限定为类而不是样式

javascript - 在 2 个不同的表中对齐行高的快速方法

html - 如何在 CSS/HTML 中模拟窗口标题栏

javascript - 我可以在隐藏文本上写一个文本吗?如果隐藏文本通过 javascript 可见,我的文本将向右移动到隐藏文本..现在可见..?

javascript - 在可编辑元素中制作一个不可编辑的 block

javascript - 在 MaterializeCSS 导航栏中垂直居中 material_icon?

html - 位置固定宽度 100%