当前位置:网站首页>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元素转换成行内块元素
边栏推荐
猜你喜欢
随机推荐
二维数组的探究
使用libwebsockets搭建一个简单的websocket服务器
C语言知识细节点(一)
2022高教社杯思路汇总A题B题C题D题
writeUP-[第五空间2019 决赛]PWN5(待进一步完善待研究内容)
2022华数杯建模A题思路解析
WinServer 2019 组策略删除本地管理员且只允许域用户登陆
Unity Shader零基础入门1:纯色物体
数据库导入导出sql数据库文件
QT页面跳转的实现
The practical skills Vim _1. Vim way of solving problems
The practical skills Vim _5. Move quickly between files and documents
微信小程序学习记录(一)
PhotoshopCS6视频教程学习笔记-基础部分之一
webSocket的实现
unity中AO、metallic、roughness贴图的使用方式
Heap series _0x04: Internal structure of heap (_HEAP=_HEAP_SEGMENT+_HEAP_ENTRY)
NAT-UDP穿透详解与实践
Unity Shader 透视效果/XRay
2022华数杯A题: 环形振荡器的优化设计 - 思路