当前位置:网站首页>display属性的使用
display属性的使用
2022-08-09 15:04:00 【恁180】
display的属性
可选值:none 将元素隐藏
block 将元素转成块元素
inline 将元素转成行内元素
inline-block 将元素转换成行内块元素
例如下面代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
span{
color: red;
width: 200px;
height: 100px;
background-color: green;
text-align: center;
display: none;
}
div{
background-color: pink;
width: 200px;
height: 100px;
text-align: center;
}
</style>
</head>
<body>
<div>好好学习,天天向上<br>
<span>欢迎新同学</span>
</div>
</body>
</html>
上述代码将sapn的元素隐藏掉了
运行结果如图所示:

span{
color: red;
width: 200px;
height: 100px;
background-color: green;
text-align: center;
/* line-height: 100px; */
/*实现元素之间的相互转换
display属性
可选值:
none 将元素隐藏
block 将元素转成块元素
inline 将元素转成行内元素
inline-block 将元素转成行内块元素
*/
display: block;
}上面代码将span元素转换成块元素
运行结果如图所示:
span{
color: red;
width: 200px;
height: 100px;
background-color: green;
text-align: center;
display: inline;
}上述代码将span转换成行内元素
结果如图所示

span{
color: red;
width: 200px;
height: 100px;
background-color: green;
text-align: center;
display: inline-block;
}上面代码将span元素转换成行内块元素

边栏推荐
猜你喜欢
随机推荐
GStreamer应用开发手册学习笔记之二
js事件流
Jenkins Pipeline编写思路与技巧
2022华数杯C题:插层熔喷非织造材料的性能控制研究 - 思路
Tracert 命令穿越防火墙不显示星号*的方法
(十)打包和项目部署
Typescript学习(一)
C语言,输入一个10以内的随机数,按要求求得表达式的值。
Heap series _0x04: Internal structure of heap (_HEAP=_HEAP_SEGMENT+_HEAP_ENTRY)
VRRP详解与配置实例
Win10 Runas 命令 域用户以管理员权限运行
JS字符串对象基础操作方法
Unity Shader 透视效果/XRay
List,Set,Map,Queue,Deque,Stack遍历方式总结
FFmpeg源码剖析-通用:ffmpeg_parse_options()
typescript学习(二)
2022.7.22FPGA学习总结:项目实践——按键消抖模块
Gin框架(一):基础概览
Unity Shader零基础入门4:纹理贴图与法线贴图
opacity和rgba的区别









