当前位置:网站首页>37 element mode (inline element, block element, inline block element)
37 element mode (inline element, block element, inline block element)
2022-07-25 14:43:00 【hello_ sunny123】
CSS Element display mode
Understanding the display mode of elements can better let us layout the page .
1. What is the display mode of elements
effect : There are lots of tags on Web pages , Different types of tags are used in different places , Understanding their characteristics can better layout our web pages .
The element display mode is the element ( label ) How to display , such as <div> Own a line , For example, you can put more than one in a row <span>.
HTML Elements are generally divided into block elements and inline elements .
2. Classification of element display patterns
One . A block element
Common block elements are <hl>~<h6>、<p>、<div>、<ul>, <ol>、<li> etc. , among <div> Tags are the most typical block elements .
Characteristics of block level elements :
(1) More domineering , Own a line .
(2) Height , Width 、 Both the outer and inner margins can be controlled .
(3) The width is the container by default ( Parent width ) Of 100%
(4) It's a container and a box , It can release internal or block level elements .
Be careful :
Block level elements cannot be used inside elements of a text class
<p> Labels are mainly used for storing words , therefore <p> You can't put block level elements in it , In particular, we can't put <div>
Empathy , <hl>~<h6> And so on are text class block level labels , You can't put other block level elements in it
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Block-level elements </title>
<style> div {
width: 200px; height: 200px; background-color: pink; } </style>
</head>
<body>
<div> More domineering , Own a line </div> shivering
<!-- <p> <div> There's a problem here </div> </p> -->
</body>
</html>
Running results

Error demonstration code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Block-level elements </title>
<style> div {
/* width: 200px; */ height: 200px; background-color: pink; } </style>
</head>
<body>
<div> More domineering , Own a line </div> shivering
/* `<p>` Labels are mainly used for storing words , therefore `<p>` You can't put block level elements in it , In particular, we can't put `<div>`*/
<p>
<div> There's a problem here </div>
</p>
</body>
</html>
Running results

Two . Inline elements
Common inline elements are <a>、<strong>、<b>、<em>、<i>、<del>、<s>、<ins>、<u>、<span> etc. , among <span> Tags are the most typical inline elements .
In some places, inline elements are also called inline elements .
Characteristics of the elements in the line :
(1) Elements in adjacent lines are on one line , One line can display multiple .
(2) high 、 The direct setting is invalid .
(3) The default completion is the completion of its own content .
(4) Inline elements can only hold text or other inline elements .
Be careful :
No more links in the links
Special case Links You can put block level elements in it , But to It's safest to switch to block level mode
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Inline elements </title>
<style> span {
width: 100px; height: 100px; background-color: hotpink; } </style>
</head>
<body>
<span>pink Teacher, how do you wear good clothes </span> <strong> Clothes of good taste </strong>
<span>pink teacher </span> <strong> Clothes of good taste </strong>
</body>
</html>
Running results

3、 ... and . Inline block element
Inline block element
There are several special tags in the line elements <td>、<input/>、<img/> , They have the characteristics of both block elements and inline elements .
Some data call them inline block elements .
Characteristics of block elements in the line :
(1) And the adjacent line elements ( Block in row ) On one line , But there will be gaps between them . One line can display multiple ( In line element features ).
(2) The default width is the width of its own content ( In line element features ).
(3) Height , Row height 、 Both the outer and inner margins can be controlled ( Block level element features ).
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Inline block element </title>
<style> input {
width: 249px; height: 25px; } </style>
</head>
<body>
<input type="text">
<input type="text">
</body>
</html>
Running results

summary

3. Element display mode conversion
边栏推荐
- Idea error failed to determine a suitable driver class
- 关于ROS2安装connext RMW的进度条卡在13%问题的解决办法
- 应用实践:Paddle分类模型大集成者[PaddleHub、Finetune、prompt]
- 基于浏览器的分屏阅读
- sudo rosdep init Error ROS安装问题解决方案
- 快速搭建Dobbo小Demo
- 51单片机学习笔记(1)
- SQL优化的一些建议,希望可以帮到和我一样被SQL折磨的你
- 为什么中建、中铁都需要这本证书?究竟是什么原因?
- How to make a set of code fit all kinds of screens perfectly?
猜你喜欢

39 简洁版小米侧边栏练习

Ssh server rejected password
![[MySQL must know and know] trigger | permission management](/img/59/cb805d972097a6a8ed7f3ae454a91d.png)
[MySQL must know and know] trigger | permission management

GameFramework制作游戏(一)

The supply chain collaborative management system, a new "engine" of digitalization in machinery manufacturing industry, helps enterprises' refined management to a new level

006操作符简介

Gonzalez Digital Image Processing Chapter 1 Introduction

牛客多校 E G J L
![Number of high-quality number pairs [bit operation characteristics + abstract ability evaluation + grouping fast statistics]](/img/c9/8f8f0934111f7ae8f8abd656d92f12.png)
Number of high-quality number pairs [bit operation characteristics + abstract ability evaluation + grouping fast statistics]

冈萨雷斯 数字图像处理 第一章绪论
随机推荐
Niuke multi school E G J L
Writing standard of physical quantities and unit symbols
44 新浪导航 ,小米边栏 练习
软件测试 -- 1 软件测试知识大纲梳理
【MySQL系列】-索引知多少
基于AMD EPYC服务器的EDA芯片设计解决方案
Educational codeforces round 132 (rated for Div. 2) C, d+ac automata
阿里云安装MYSQL5.7
Educational Codeforces Round 132 (Rated for Div. 2) C,D+AC自动机
优质数对的数目[位运算特点+抽象能力考察+分组快速统计]
The main function of component procurement system, digital procurement helps component enterprises develop rapidly
51单片机学习笔记(1)
C language and SQL Server database technology
D2. picking carrots (hard version) (one question per day)
BIO、NIO、AIO示例
如何让一套代码完美适配各种屏幕?
L1和L2正则化
Gson and fastjson
二维数组赋初值你会几种方法?
Jqgrid select all cancel single line click cancel event