html - div不能和screen一样宽,另一个div不允许

标签 html css twitter-bootstrap

我想让红色的 div 与屏幕宽度相同。但它与另一个 div 对齐,不能全宽。

红色 div 区域在绿色 div 之前可用,但我希望它是全宽的。

此外,我希望红色 div 垂直和水平居中。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="col-12 mt-2" style="border-radius: 12px; height: 250px; background-color: #5b6269">


  <div class="position-fixed-top border bg-info float-right"
  style="
    border-bottom-right-radius: 20px;
    border-bottom-left-radius: 20px;
    font-size: 30px;
    background-color: green;
    ">
      ئـۆفـه‌ری رۆژانــه‌
  </div>


  <div class="h-100 row align-items-center justify-content-center">
    <div class="col-12" style="background:red">
      Content content content content
    </div>
  </div>
</div>

最佳答案

您在标题上使用了 float-right 类,这使得下面的 div 不会 float 到整个宽度,添加一个带有 class="clearfix"的空 div 将解决您的问题。

这是决议的笔。 https://codepen.io/mohammad-aslam/pen/axBxPP

<div class="col-12 mt-2" style="border-radius: 12px; height: 250px; background-color: #5b6269">


        <div class="position-fixed-top border bg-info float-right" style=" border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; font-size: 30px;background-color: green;">ئـۆفـه‌ری رۆژانــه‌
        </div>

<div class="clearfix"></div>
        <div class="h-100 row align-items-center justify-content-center">
            <div class="col-12" style="background:red">
                Content content content content
            </div>
        </div>
        </div>

希望对您有所帮助。

关于html - div不能和screen一样宽,另一个div不允许,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55587581/

相关文章:

javascript - 单击时展开一个 div(具有悬停翻转效果)

jquery - jQuery 中的元素样式

html - 尝试在angularjs中提交没有有效数据的表单时弹出错误消息

javascript - 调整视口(viewport)大小时输入框没有间隔( Bootstrap )

php - 选择正在传递的项目值而不是文本值到mysql数据库实时成本计算

html - 为不同的设备尺寸编写媒体查询

javascript - 我们如何设置 DOM 中已加载图像的元素的背景图像?

html - 在业务催化剂中设计表单样式,用于数据捕获

javascript - 你如何使溢出的 float 元素居中?

css - 调整宽度内容