<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html, body {
padding: 0;
margin: 0;
/* height: 2400px; */
height: 100%;
background: lightgray;
}
.container {
width: 400px;
}
.header {
height: 50px;
background: red;
}
.body {
height: 100px;
background: yellow;
width: 600px;
}
</style>
</head>
<body>
<div class="container">
<div class="header"></div>
<div class="body"></div>
</div>
</body>
</html>

上面的例子body比container还宽,header使用了container的宽度,所以出现了上短下长。

让container设置min-width: fit-content能解决这个问题。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html, body {
padding: 0;
margin: 0;
/* height: 2400px; */
height: 100%;
background: lightgray;
}
.container {
width: 400px;
min-width: fit-content;
}
.header {
height: 50px;
background: red;
}
.body {
height: 100px;
background: yellow;
width: 600px;
}
</style>
</head>
<body>
<div class="container">
<div class="header"></div>
<div class="body"></div>
</div>
</body>
</html>

最新文章

  1. C++01.类的引入
  2. Sublime Text配置Python开发利器
  3. Java Lambda表达式初探
  4. POI2007_zap 莫比乌斯反演
  5. JavaWeb---总结(四)Tomcat服务器学习和使用(二)
  6. OpenCV成长之路(9):特征点检测与图像匹配
  7. schemaLocation value = &#39;xxxxxxxxxxxx&#39; must have even number of URI&#39;s
  8. 查看oracle SID
  9. list排序成员函数对string对象与char*对象排序的差别
  10. 新测 thinkphp3.2 整合 PHPMailer 发送邮件
  11. Hibernate: merge方法
  12. Cocos2d-X学习之Ref类
  13. 关于Update语句的锁
  14. Objective-C 是如何慢慢走红的?
  15. bbs论坛流程
  16. redis学习(六)——Sorted Set数据类型
  17. C#获取程序运行时间
  18. HOOK -- DLL的远程注入技术详解(1)
  19. SpringMVC源码阅读入门
  20. OC Foundation框架—字符串

热门文章

  1. css实现弹框
  2. Apache Struts 2 漏洞汇总
  3. SpringBoot接入两套kafka集群
  4. 【多线程】创建线程方式二:实现Runnable接口
  5. CentOS下sudo的使用和sudoers配置
  6. MVC 调试页面路径变成 Views/Controller/Action.cshtml问题
  7. ftp多文件压缩下载
  8. conda和pip加速参考
  9. mysql数据恢复 根据旧备份的sql文件和当前data下的ibd文件恢复innodb引擎数据
  10. Conda 虚拟环境移植