Home  >  Article  >  Web Front-end  >  How block elements are converted to inline elements

How block elements are converted to inline elements

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-04-20 09:41:263458browse

This article will give you a detailed introduction to the method of converting block elements and inline elements. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How block elements are converted to inline elements

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.div1{
				width: 200px;
				height: 200px;
				background-color: lightyellow;
				border: 1px solid lightcoral;
				margin: 0px auto;
			}
			.s1{
				/*行内元素设置宽和高未必有效
				*块元素设置宽和高一定有效的
				* */
				width: 100px;
				height: 100px;
				background-color: greenyellow;
				border: 1px solid blue;
				/*span 是一个行内元素  
				* 行内元素没有盒子模型
				* 行内元素没有办法设置内边距和外边距特征
				* 只有块标签才有盒子模型  才可以设置内边距和外边距
				* 如果一个行内标签 非要使用盒子模型那么可以将行内元素转换为块元素
				* display  block 行内转换为块    inline 块转换为行内
				*  */
				display: block;
				margin-top: 20px;
			}
		</style>
	</head>
	<body>
		<div class="div1">
			<span class="s1">今天是3月6号</span>
		</div>
	</body>
</html>

Recommended learning: css video tutorial

The above is the detailed content of How block elements are converted to inline elements. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete