鱼C论坛

 找回密码
 立即注册
查看: 3544|回复: 3

html中设置overflow:auto

[复制链接]
发表于 2019-5-18 11:54:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
请问一下我将<body>的高度设置比<html>的高度大,然后把<html>中加上overflow:auto;为什么html没有完全包裹body.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
html{height:100px;border:10px black solid;background:gray;overflow:auto;}
body{margin:0; height:300px;border:10px green solid;background:blue;}
</style>
</head>
<body>
</body>
</html>
QQ图片20190518115045.png
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-5-20 06:52:42 | 显示全部楼层
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>鱼C论坛</title>
  6. <style>
  7. div.ex1 {
  8.     background-color: lightblue;
  9.     width: 110px;
  10.     height: 110px;
  11.     overflow: scroll;
  12. }
  13. div.ex2 {
  14.     background-color: lightblue;
  15.     width: 110px;
  16.     height: 110px;
  17.     overflow: hidden;
  18. }
  19. div.ex3 {
  20.     background-color: lightblue;
  21.     width: 110px;
  22.     height: 110px;
  23.     overflow: auto;
  24. }
  25. div.ex4 {
  26.     background-color: lightblue;
  27.     width: 110px;
  28.     height: 110px;
  29.     overflow: visible;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <h1>overflow 属性</h1>
  35. <p>如果元素中的内容超出了给定的宽度和高度属性,overflow 属性可以确定是否显示滚动条等行为。</p>
  36. <h2>overflow: scroll:</h2>
  37. <div class="ex1">鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!</div>
  38. <h2>overflow: hidden:</h2>
  39. <div class="ex2">鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!</div>
  40. <h2>overflow: auto:</h2>
  41. <div class="ex3">鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!</div>
  42. <h2>overflow: visible (默认):</h2>
  43. <div class="ex4">鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!鱼C论坛 -- 学的不仅是技术,更是梦想!!!</div>
  44. </body>
  45. </html>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-5-20 06:54:06 | 显示全部楼层
overflow 属性正确食用方法
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-5-20 08:51:04 | 显示全部楼层
你好,正常使用我能明白的,就是不知道要怎么解释在<html>中加overflow的现象。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-8 08:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表