html - 为 div only css 设置相同的高度和响应度

标签 html css height responsiveness

我有两个 div,它们的大小应该相同。我试图设置一个适合桌面大小的高度,但是当我使用不同的平台时,它变得一团糟

 ____________
|  ___________                 
| |         | |
| |         | |  
| |         | |
|_|_________  |
  |___________|

.custombox {
  text-align: center;
  padding: 10px;
  position: absolute;
  border: 1px solid;
}

.customparentbox {
  background: red
}
<div class="customparentbox">
  <div class="custombox">
    <p>Sample text</p>
    <button>test</button>
  </div>
</div>

最佳答案

我对你的 CSS 做了一些修改

来自

.custombox{
  text-align: center;
  padding: 10px;
  position: absolute;
  border: 1px solid;}
  .customparentbox{background:red}

.custombox {
  text-align: center;
  padding: 10px;
  position: relative;
  top:10px;
  left:10px;
  border: 1px solid;
}

.customparentbox {
  width:100px;
  background: red;
  border:1px solid green;
}

这是一个jsfiddle我做了。

关于html - 为 div only css 设置相同的高度和响应度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45972093/

相关文章:

c++ - 如何在 Gtk::TextView 中设置可见行数?

html - 切换按钮和搜索栏偶尔显示错位

javascript - 仅使用 HTML 和 Javascript 进行开发?

javascript - ReactJS 中的 CSS - 媒体查询和分组选择器

css - 如何使用 TAL 创建斑马条纹 CSS?

html - 使用 Bootstrap 显示输入和标签同一行

javascript - 内部 html 被 javascript 更改后自动调整 div 高度

html - 仅限 CSS - 带有滚动条的动态标题高度和 100% 内容高度

jquery - chzn-select 不需要的下拉列表创建了 jquery

javascript - jquery 只克隆文本而不是属性不起作用