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

How block elements are converted to inline elements

醉折花枝作酒筹
Release: 2021-04-20 09:41:26
forward
3521 people have browsed it

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>
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template