html - 将右边的 div 包裹在左边的 div 周围

标签 html css

我正试图将我的右侧 div 包裹在我的左侧,呈倒月亮形状?这是它现在的样子。

current div

我想要做的是让红色 block 环绕黑色 block 的圆 Angular 。这是当前的 HTML/CSS 代码,如果 CSS 代码有点“困惑”,我深表歉意,因为我已经尝试过不同的代码。

HTML

<div class="container full-width">
  <div class="row proj">
    <div class="col-md-8 full-width">          
      <div class="content">          
      </div>
    </div>
    <div class="col-md-4 full-width">          
      <div class="options">
      </div>
    </div>  
  </div>
</div>

CSS

 .content { 
    margin-top: 75px;
    position: relative;
    width: 70vw;
    max-width: 100%;
    height: 90vh;
    max-height: 100%;
    overflow: hidden;
    background-color: black;
    border-radius: 0 50vw 50vw 0;   
}

.options {  
    margin-top: 75px;
    position: relative;
    width: 30vw;
    max-width: 100%;
    height: 90vh;
    max-height: 100%;
    overflow: hidden;
    background-color: red;  
}

.container .full-width{ 
    padding-left: 0;
    padding-right: 0;    
    overflow-x: hidden;
}

更新

已找到答案,感谢您的帮助,因此不得不根据您发布的代码稍微调整一下代码,现在看起来像这样。

.content { 
   margin-top: 75px;
    width: 30vw;
    height: 90vh;
    overflow: hidden;
    background-color: black;
    border-radius: 0 50vw 50vw 0;   
    float:left;
    position:relative;
    z-index:2;     
}

.options {  
    margin-top: 75px;
    margin-left:3%;
    position:relative;
    float:right;
    width: 30vw;
    height: 90vh;
    max-height: 100%;
    overflow: hidden;
    background-color: red;      
}

.container .full-width{ 
    position: absolute;
    padding-left: 0;
    padding-right: 0;

}

最后的结果是这样的,会再调整一下位置,但结果是我想要的,再次感谢。

current div

更新 2

好吧,不得不再做一次编辑,出于某种原因我不得不将它们都向左浮动。否则,如果我保持红色 div 向右浮动并尝试扩大其宽度,它会向左扩大,知道为什么吗?当前代码:

.content { 
   margin-top: 75px;
    width: 44vw;
    height: 90vh;
    overflow: hidden;
    background-color: black;
    border-radius: 0 50vw 50vw 0;   
    float:left;
    position:relative;
    z-index:2;     
}

.options {  
    margin-top: 75px;
    margin-left:20%;
    position:relative;
    float:left;
    width: 50vw;
    height: 90vh;
    max-height: 100%;
    overflow: hidden;
    background-color: red;      
}

.container .full-width{ 
    position: absolute;
    padding-left: 0;
    padding-right: 0;

}

最佳答案

使用position:relative;对于 content 和 position:absolute;对于选项

 .content { 
    width: 30vw;
    height: 90vh;
    overflow: hidden;
    background-color: black;
    border-radius: 0 50vw 50vw 0;   
    float:left;
    position:relative;
    z-index:2;
}

.options {  
    margin-left:3%;
    position:absolute;
    float:right;
    width: 30vw;
    height: 90vh;
    max-height: 100%;
    overflow: hidden;
    background-color: red;  
}
<div class="container full-width">
      <div class="row proj">
        <div class="col-md-8 full-width">          
          <div class="content">          
          </div>
        </div>
        <div class="col-md-4 full-width">          
          <div class="options">
          </div>
        </div>  
    </div>

关于html - 将右边的 div 包裹在左边的 div 周围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42081508/

相关文章:

html - 垂直对齐不适用于 float 元素

javascript - 使用 Math.Random() 修改 CSS 文件;

css - 如何在没有媒体查询的情况下处理响应式表单布局

html - CSS float ul 列表和段落

javascript - 如何通过单击 anchor 标记来禁用 body 标记上的 onload 功能?

javascript - 当同级 div 收缩或扩展时,保持 div 中的滚动位置?

CSS:根据单页导航中的 ID 在部分中定位 DIV

javascript - 使用 JavaScript/ajax 在单击按钮上更改特定 TD 的背景颜色

javascript - 使用firebase登录后页面反复刷新

javascript - Bootstrap 4 崩溃不适用于 jquery 缩小版