我想要一個背景圖像,它始終是內容的大小。不是屏幕的大小!這樣我可以向下滾動到圖像的底部。有沒有任何的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. CSS背景圖像調整大小
- 4. CSS背景圖像大小50%
- 5. 背景圖像內存大小
- 6. 背景大小與css sprite圖像中的背景位置
- 7. 使用CSS調整背景圖片和內容的大小
- 8. 背景圖像大小iphone
- 9. body.class背景圖像大小
- 10. Android:背景圖像大小
- 11. 鎖背景圖像大小
- 12. CSS:如何設置容器大小等於背景圖像大小
- 13. CSS:使背景圖像顯示沒有內容和/或固定大小?
- 14. CSS背景圖像+跨度圖像整個大小的DIV
- 15. 內嵌CSS背景大小的蓋
- 16. CSS背景圖像 - 縮小以適合固定大小div
- 17. iOS 4最大CSS背景圖像大小?
- 18. 背景圖像CSS
- 19. CSS背景圖像
- 20. 背景圖像css
- 21. CSS背景圖像
- 22. CSS精靈背景大小
- 23. css綁定背景大小?
- 24. css背景大小縮放?
- 25. css背景大小封面
- 26. 容器css外的背景圖像
- 27. 藍圖防止CSS中的圖像100%背景大小?
- 28. 引導和CSS - 輸入按鈕背景圖像(圖標大小)
- 29. CSS縮小和背景圖像語法
- 30. CSS - 內容溢出背景圖片
把你的內容在沒有高度一個div,所以它會與內容增長。然後,執行'background-size:cover;'或'background-size:contains;'。 – Santi
請提供您的標記和您解決問題的嘗試 - 解決方案可能會因您當前的方法而異。 – Serlite