Html 我可以只溢出一个div吗?

Html 我可以只溢出一个div吗?,html,css,overflow,Html,Css,Overflow,我想知道我是否只能隐藏我的两个div中的一个,而不能隐藏另一个 我需要保持同样的结构 不确定这是否可行以下是您要做的: 杀死CSS代码的.container块中的溢出属性 然后使用top、bottom、left和right属性的值使其溢出到您想要的方向 C.对要重叠的区域使用负值。如果希望box1向右重叠100px,请设置正确的属性值-100px 是否要隐藏其中一个框?.box1{display:none;}?编辑不透明度?把它推出框架?你想让哪一个盒子溢出来,我看看能不能帮你。 <di

我想知道我是否只能隐藏我的两个div中的一个,而不能隐藏另一个

我需要保持同样的结构 不确定这是否可行

以下是您要做的:

杀死CSS代码的.container块中的溢出属性

然后使用top、bottom、left和right属性的值使其溢出到您想要的方向

C.对要重叠的区域使用负值。如果希望box1向右重叠100px,请设置正确的属性值-100px


是否要隐藏其中一个框?.box1{display:none;}?编辑不透明度?把它推出框架?你想让哪一个盒子溢出来,我看看能不能帮你。
<div class="container">
  <div class="box1"></div>
  <div class="box2"></div>
</div>

.container {
  position: relative;
  border: 1px solid red;
  width: 300px;
  height: 100px;
  overflow:hidden;
}


.box1 {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 1px solid green;
  top: 90px;
}

.box2 {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 1px solid blue;
  left: 290px;
}
right: -100px;