img{
width: 200px;
height: 200px;
position: relative;
}
.div{
width: 200px;
height: 50px;
border: 1px solid dodgerblue;
/* float: left; */
position: absolute;
top: 0;
left: 0;
/* 超出隐藏 */
overflow: hidden;
/* 文字不换行 */
white-space: nowrap;
/* 超出部分深绿好 */
text-overflow:ellipsis;
}
.box:hover .div{
background:rgb(0, 0, 0,0.8);
color: rgb(241, 4, 4);
}
.div3{
width: 200px;
height: 200px;
border: 1px solid rgb(233, 20, 55);
/* float: left; */
}
.box{
width: 200px;
height: 200px;
border: yellowgreen solid 2px;
position: relative;
}
</style>
<body>
<div class="box">
<img src="./imgs/3II0PTMN]$V[]BL36L$%[VT.png" >
<div class="div">afgdsdfbgdfsghbhgfjgfsdfasd hdf </div>
</div>
vertical-align
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.box{
height: 300px;
border: 1px solid saddlebrown;
}
img{
width: 200px;
height: 200px;
vertical-align: bottom;
}
.div03{
border: 1px solid springgreen;
width: 200px;
height: 200px;
overflow: hidden;
float: left;
}
</style>
<body>
<div class="box">
<img src="./imgs/3II0PTMN]$V[]BL36L$%[VT.png" >
<text>dsjfdjs;lgjasdgkldasobgfdsbgedrfgbahdfhrtghsdrfeghsdrf</text>
</div>
</body>
</html>