我想要一个背景图像,它始终是内容的大小。不是屏幕的大小!这样我可以向下滚动到图像的底部。有没有任何的CSS解决方案?css背景图像内容大小
回答
将您的内容包裹在div /容器中,并将该图像用作给定内容div /容器的背景图像。给DIV /容器background-size:cover;
'background-size:cover;'因为图像重复而不起作用。应该将图像拉伸至内容的大小 –
然后执行'background-repeat:no-repeat;' – Santi
不幸的是,它不能解决问题。现在图像不包括洞内容... –
CSS属性如果你想有一定规模的背景图像,这听起来像一个HTML的问题不是一个CSS多一个,请参阅:
http://www.w3schools.com/TAgs/att_body_background.asp
如果您正在寻找看中-er功能,你可能要考虑一个JavaScript的解决方案,如下列:
http://pixelcog.github.io/parallax.js/
让我知道,如果这是HEL pful,或者如果你指的是别的东西
看到中间div包含图像和文字。 LiveFiddle。任何问题请发表评论。祝你好运
body {
margin: 0;
height:100vh;
}
#top_box {
text-align: center;
height: 20%;
border: 1px solid blue;
background: red;
}
.two_area{
display:inline-flex;
}
#middle_box {
overflow: auto;
height: 280px;
background: url(http://fehlbelichtet.stefanwensing.de/wp-content/uploads/sites/6/2016/04/alte-strasse-endlos.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
background-attachment: fixed;
border: 1px solid black;
color: red;
text-align: justify;
width:50%;
}
h1.tittle {
text-align: center;
}
#middle_box_right{
width:50%;
}
#footer_box {
border: 1px solid yellow;
text-align: center;
background: blue;
color: white;
}
<div id="top_box">
<h1>
Header area
</h1>
</div>
<div class="two_area">
<div id="middle_box">
<h1 class="tittle">
Contentable Image Area
</h1> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text
of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker
including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled
it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since
the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic
typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the
printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker
including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled
it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since
the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div id="middle_box_right">
<h1 class="tittle">2nd area</h1>
</div>
</div>
<div id="footer_box">
<h1>Footer area</h1>
</div>
- 1. CSS调整大小菜单和内容背景图像
- 2. CSS背景图像调整大小
- 3. 背景图像内存大小
- 4. 背景大小与css sprite图像中的背景位置
- 5. body.class背景图像大小
- 6. CSS背景图像+跨度图像整个大小的DIV
- 7. CSS背景图像 - 缩小以适合固定大小div
- 8. 背景图像css
- 9. CSS背景图像
- 10. 背景图像CSS
- 11. CSS背景图像
- 12. css绑定背景大小?
- 13. css背景大小封面
- 14. CSS精灵背景大小
- 15. 蓝图防止CSS中的图像100%背景大小?
- 16. CSS - 内容溢出背景图片
- 17. 背景图像的最大尺寸CSS
- 18. Android背景图像比容器大
- 19. 大小的DIV背景图像
- 20. 调整图像大小,透明背景?
- 21. iPhone 7 Plus背景图像大小
- 22. 背景图像调整大小
- 23. ActionBarSherlock背景的图像大小
- 24. 在图像增加背景图片的大小为每个内容
- 25. CSS:背景颜色的背景图像
- 26. Chrome调整大小CSS背景url图像
- 27. CSS背景图像动态调整大小
- 28. CSS背景大小的失败以及图像位置
- 29. 身体自动调整大小的css图像背景
- 30. CSS过渡背景图像淡入但不动画大小
把你的内容在没有高度一个div,所以它会与内容增长。然后,执行'background-size:cover;'或'background-size:contains;'。 – Santi
请提供您的标记和您解决问题的尝试 - 解决方案可能会因您当前的方法而异。 – Serlite