html - div 不能与屏幕宽度相同,另一个 div 不允许
问题描述
我想让红色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 不会浮动到整个宽度,添加一个带有 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>
希望能帮助到你。
推荐阅读
- python - 无法获取设置 Cookie 值 python 请求标头
- amazon-web-services - 是否可以将功能/特定文件从一个 Amazon Connect 实例导入/迁移到另一个实例?
- android - 即使我在环境变量中输入了android sdk的路径,谁能解释一下
- javascript - 简单的任务列表排序 - 如何将其保存到 Firebase Firestore?
- php - 在 mcrypt 上使用谜
- python - 将每个索引的编号放在numpy的对应位置
- elasticsearch - 查询多个索引时,仅检索弹性搜索命中中的特定 _index 文档
- java - 使用杰克逊转换带有重复键的 JSON
- wordpress - 如何在使用 WP 加载页面期间阻止外部静态资源
- java - 如何测试 AOP 拦截器?