HTML/CSS盒子模型 display,overflow的作用
一 display
/* 把块元素 转为 行元素 */
/* display: inline; */
/* 元素隐藏 none */
display: none;
/* 把行元素 转为 块元素 */
/* display: block; */
/* 行快元素 */
display: inline-block;
单双标签
单标签 : hr,br,img,input,frame
双标签 : h1-h6,p,div,span,a,b,strong,em,i,sup,sub,del,table,tr,td,th,form,label,iframe,frameset
行块标签:
行标签:一行可以显示多个,不能设置宽高
span,a,b,strong,i,em,sup,sub,del,input
块标签:独占一行,可以设置宽高
div,h1-h6,p,table
行快标签:既可以在一行显示,又可以设置宽高
img
-->
<!-- 块元素 -->
<div class="box">hello</div>
<div class="box1">world</div>
<!-- 行元素 -->
<span class="sp1">hello</span>
<span>world</span>
二 overflow
scroll 不管内容有没有溢出,都会有滚动条
auto 文字超出显示滚动条,否则不显示
溢出、超出部分隐藏
三 border 边框
边框:线粗细 线颜色 线样式
border:width style color
border:2px red solid (顺序可以变动)
线粗细:默认3px
边框可以实现:css创建三角形效果
四 padding 内边距
五 margin 外边距
盒模型构成
内容 + border边框 + padding内边距 + margin外边距<!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>
.box1{
width: 180px;
height: 140px;
background-color: aqua;
font-size: 30px;
}
.box2{
width: 100px;
height: 100px;
background-color: rgb(21, 4, 255);
display: inline-block;
}
.box3{
width: 100px;
height: 100px;
display: inline-block;
background-color: rgb(128, 0, 0);
}
</style>
</head>
<body>
<!-- 盒模型 -->
<div class="box1">我是1</div>
<div class="box2">我是2</div>
<div class="box1">我是3</div>
</body>
</html>
本文作者:五季-子琛
本文链接:https://www.cnblogs.com/izichen/articles/17755675.html

浙公网安备 33010602011771号