為什么我設定了item2 的 right 和 bottom,以及 item2 的寬高,它就可以向上伸展,而不是基于right 和 bottom向下伸展?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
.box {
position: relative;
width: 300px;
height: 100px;
border: 10px solid red;
box-sizing: border-box;
}
.item2 {
position: absolute;
right: -10px;
bottom: -10px;
width: 0px;
height: 0px;
box-sizing: border-box;
border: 10px solid transparent;
}
.box:hover .item2 {
box-sizing: border-box;
width: 300px;
height: 100px;
border-color: black;
transition: all 1s;
}
</style>
</head>
<body>
<div class="box">
<div class="item2"></div>
</div>
</body>
</html>
uj5u.com熱心網友回復:
你可以理解為 你把item2定位在了右下角。如果你希望他往下和往右延展,那么你就把它定位在左上角。

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/256569.html
標籤:HTML(CSS)
