我創建了一個部分,其中有一個 div(影像的包裝器)我試圖為 div 和部分提供高度屬性但它不起作用我知道關于 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=&auto=format&fit=crop&w=500&q=60" alt="">
</div>
</section>
所以請誰能告訴我為什么它不起作用以及如何使高度屬性起作用?
uj5u.com熱心網友回復:
溢位作業正常:
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=&auto=format&fit=crop&w=500&q=60" alt="">
</div>
</section>
uj5u.com熱心網友回復:
試試這個把浮動留給部分和 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=&auto=format&fit=crop&w=500&q=60" alt="">
</div>
</section>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/384472.html
