gpt4 book ai didi

javascript - 清除不适用于我的 div

转载 作者:太空宇宙 更新时间:2023-11-04 04:26:33 25 4
gpt4 key购买 nike

我有一个代码片段,我正在尝试清除黄色部分下的橙色部分。为什么 clear:left 不起作用?

http://jsfiddle.net/w5K4j/14/

#parent {
height:300px;
width:100px;
float:left;
border: 1px solid;
}

#unknown {
float:right;
height:50px;
width:20px;
clear:left; /* Shouldn't it make child(orange) div to float under? */
background-color: yellow
}

#child {
float:right;
height:100px;
width:50px;
background-color: orange;
/*text-align: center;*/
}

最佳答案

如果我没理解错的话,你应该清除 #child 并使用 right 值:

#child {
float:right;
clear: right;
height:100px;
width:50px;
background-color: orange;
/*text-align: center;*/
}

http://jsfiddle.net/w5K4j/15/

关于javascript - 清除不适用于我的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18161490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com