CSS-盒子模型元素溢出

作用:控制溢出的元素的内容的显示方式

属性:overflow

属性值

属性值 效果
hidden 溢出隐藏
scroll 溢出滚动(无论是否溢出,都显示滚动条位置)
auto 溢出滚动(溢出才显示滚动条位置)
html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

     div{
       width:100px;
       height: 100px;
       background-color: red;
     }
   
     
    </style>
</head>
<body>
<div>hello world hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world</div>

</body>
</html>

正常情况下,网页是这个样子的,当文本超出了行高之后

使用了属性overflow之后,溢出的部分都被隐藏住了

相关推荐
雾岛听风6913 小时前
JavaScript基础语法速查手册
开发语言·前端·javascript
遇见~未来3 小时前
第三篇_现代布局_从弹性到网格
前端·css3
前端那点事3 小时前
Vue前端SEO优化全攻略(实操落地版,新手也能上手)
前端·vue.js
Dxy12393102163 小时前
HTML 如何使用 SVG 画曲线
前端·算法·html
用户2367829801683 小时前
从零实现 GIF 制作工具:LZW 压缩与 Median Cut 色彩量化
前端·javascript
hahaha 1hhh3 小时前
中文乱码 ubuntu autodl
linux·运维·前端
Codebee4 小时前
Harness Engineering:AICode 的灵魂
前端·人工智能·前端框架
Highcharts.js4 小时前
线形比赛积分增长或竞赛图|Highcharts企业图表代码示列
开发语言·前端·javascript·折线图·highcharts·竞赛图
hpysirius4 小时前
在企业搭建一套完整的AI Agent系统
前端
追逐梦想永不停4 小时前
记录一个好用的excel判断数字格式的公式
前端·chrome·excel