相关疑难解决方法(0)

为什么width:auto行为不同于height:auto?

我没有auto价值。如果应用height它,将采用孩子的身高,但是如果应用width它,将采用父母的身高。

auto值本身没有MDN帖子,并且Google会生成“ 100%VS自动”匹配,而不是“ width:auto VS height:auto”匹配。

为了满足我当前的需求,我希望将一个元素扩展到其孩子的宽度,但总的来说,我希望知道如何处理auto

 .divXS {
   width: 100px;
   height: 100px;
   background: green;
 }
 
 .divXXS {
   width: 50px;
   height: 50px;
   background: yellow;
 }
 
 .divSM {
   width: 200px;
   height: 200px;
 }
 
 #Father {
   background: blue;
   border: 3px solid #20295E;
 }
 
 #Mother {
   background: pink;
   border: 3px solid #DB6DBE;
 }
 
 #Daughter {
   width: 100%;
   height: 100%;
 }
 
 #Son {
   width: auto;
   height: auto;
 }
Run Code Online (Sandbox Code Playgroud)
<div class="divSM" id="Mother">
  <div class="divXS" id="Daughter"> …
Run Code Online (Sandbox Code Playgroud)

html css

5
推荐指数
1
解决办法
159
查看次数

标签 统计

css ×1

html ×1