x
 
<!DOCTYPE html>
<html>
<head>
<style> 
#main {
  width: 220px;
  height: 300px;
  border: 1px solid black;
  display: flex;
  align-items: flex-start;
}
#main div {
  flex: 1;
}
#myBlueDiv {
  align-self: center;
}
</style>
</head>
<body>
<h1>HTML Style 对象</h1>
<h2>alignSelf 属性</h2>
<div id="main">
  <div style="background-color:coral;">红色</div>
  <div style="background-color:lightblue;" id="myBlueDiv">蓝色</div>  
  <div style="background-color:lightgreen;">有更多内容的绿色 DIV。</div>
</div>
<p>单击按钮将 alignSelf 属性的值设置为“stretch”。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
  document.getElementById("myBlueDiv").style.alignSelf = "stretch";
}
</script>
</body>
</html>