这将产生正确的结果:CSS类忽略列表
#container {
display: flex;
}
#red_box {
height: 30%;
width: 30%;
background-color: red;
}
<div id ="container">
<div id="red_box">a</div>
<div id="blu_box">b</div>
</div>
当我移动height属性到它自己的类,并给予元素两种风格,高度被忽略。
#container {
display: flex;
}
#box {
height: 30%
}
#red_box {
width: 30%;
background-color: red;
}
<div id ="container">
<div class="box red_box">a</div>
<div class="box blu_box">b</div>
</div>
使用类正确的代码,您没有任何类选择。 – SLaks
他们是'class'而不是'id'。您正在使用'id'选择器(带'#'前缀)而不是类选择器。 – Harry
'#red_box'是为id而不是类。 '.red_box'是。 –