使用JavaScript设置项目相对于其他项目的收缩方式?
使用flexShrink 属性设置项目相对于JavaScript其余项目的收缩程度。
示例
您可以尝试运行以下代码以了解如何使用flexGrow 属性-
<!DOCTYPE html>
<html>
<head>
<style>
#box {
border: 1px solid #000000;
width: 500px;
height: 100px;
display: flex;
}
#box div {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 300px;
}
</style>
</head>
<body>
<div id = "box">
<div style = "background-color:orange;">DIV1</div>
<div style = "background-color:yellow;" id = "myID">DIV2</div>
</div>
<p>Using flexShrink property</p>
<button onclick = "display()">Set</button>
<script>
function display() {
document.getElementById("myID").style.flexShrink = "5";
}
</script>
</body>
</html>热门推荐
10 贺卡文字同事祝福语简短
11 人民子弟春节祝福语简短
12 苦难的成语祝福语简短
13 侄儿生日祝福语简短独特
14 新年恋人祝福语简短创意
15 生日寿宴祝福语简短精辟
16 祝福语同事离职英文简短
17 牛年佛家祝福语大全简短
18 女性生日祝福语简短优美