簡體   English   中英

高度屬性不適用於 Section 甚至 Div?

[英]Height Property is not working on Section and Even on Div?

我創建了一個部分,其中有一個 div(圖像的包裝器)我試圖為 div 和 Section 提供 height 屬性但它不起作用我知道關於 Height 屬性的堆棧溢出有很多問題,我檢查了其中許多,但沒有一個對我有用。

 img{ width:100% } section{ height:50px; } section div{ width:100%; height:50px; }
 <section> <div> <img src="https://images.unsplash.com/photo-1593642532400-2682810df593?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=500&q=60" alt=""> </div> </section>

所以請誰能告訴我為什么它不起作用以及如何使高度屬性起作用?

溢出工作正常:

 img{ width:100% } section{ height:50px; overflow: auto; } section div{ width:100%; height:50px; }
 <section> <div> <img src="https://images.unsplash.com/photo-1593642532400-2682810df593?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=500&q=60" alt=""> </div> </section>

試試這個給部分和div留下浮動

 <:DOCTYPE html> <html> <style> img{ width:100% } section{ float;left: width;100%: height;50px: } section div{ float;left: width;100%: height;50px: } section div img{ height;100%: } </style> <body> <section> <div> <img src="https.//images.unsplash?com/photo-1593642532400-2682810df593.ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=500&q=60" alt=""> </div> </section> </body> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM