Detailed explanation of display modes in CSS tags

Detailed explanation of display modes in CSS tags Case diagram

insert image description here

Code

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<style type="text/css">
		a{
            display:inline-block;
            width:100px;
            height:50px;
            background:#f00;
            text-align:center;
            text-decoration:none;
            color:#fff;
            line-height:50px;
        }
		body{text-align:center;}
	</style>
</head>
<body>

<a href="">Navigation</a>
<a href="">Navigation</a>
<a href="">Navigation</a>
<a href="">Navigation</a>
<a href="">Navigation</a>
<a href="">Navigation</a>

</body>
</html>

Summarize

This is the end of this article about the display mode in CSS tags. For more relevant CSS tag display mode content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

Label display mode (important)

div and span tags

1. The styles are exactly the same, but the labels are different, and the displayed results are completely different

2. Each div will occupy a row, and multiple spans will be arranged in a row

1. Block Elements

Features: The default width is 100%, the default height is 0, the width and height can be set, it will inherit the width of the parent, and it will display in line breaks—div ul li ph

Schematic diagram

insert image description here

Summary: Block elements can add width and height attributes and occupy a single line

2. Row Elements

Features: The default width and height are both 0, width and height cannot be set, one line display ---- span biua

Schematic diagram

insert image description here

Summary: Insensitive to width and height, cannot occupy a single line

3. Block elements within the line

Features: can only set width and height, can not wrap display - img input

Schematic diagram

insert image description here

Learn one more trick: Generally speaking, block elements in a line are also inline elements. Some operations on inline elements can also operate on block elements in a line, for example: text-align:center;line-height:1000px;

4. Mode conversion

Syntax: display:值

Value: block turns into a block element, inline turns into a row element, inline-block turns into a block element within the row, none hides the element

Learn one more trick: After using this attribute to hide the element, it will not occupy space on the page

Small case: the production of simple navigation

<<:  Html comments Symbols for marking text comments in Html

>>:  Solution to transparent font problem after turning on ClearType in IE

Recommend

Use CSS to easily implement some frequently appearing weird buttons

background In the group, some students will ask r...

How to replace all tags in html text

(?i) means do not match case. Replace all uppercas...

A question about border-radius value setting

Problem Record Today I was going to complete a sm...

How to add a disk in Vmware: Expand the disk

This article describes how to add or expand a dis...

HTML table tag tutorial (26): cell tag

The attributes of the <TD> tag are used to ...

Pure CSS to achieve the water drop animation button in Material Design

Preface You should often see this kind of special...

A detailed introduction to for/of, for/in in JavaScript

Table of contents In JavaScript , there are sever...

A brief understanding of the difference between MySQL union all and union

Union is a union operation on the data, excluding...

Summary of Common Problems with Mysql Indexes

Q1: What indexes does the database have? What are...

In-depth analysis of MySQL execution plans

Preface In the previous interview process, when a...

Detailed explanation of json file writing format

Table of contents What is JSON Why this technolog...

Detailed explanation of the principle and usage of MySQL views

This article uses examples to illustrate the prin...

Summary of related functions for Mysql query JSON results

The JSON format field is a new attribute added in...

Detailed explanation of the difference between $router and $route in Vue

We usually use routing in vue projects, and vue-r...

How to run the springboot project in docker

1. Click Terminal below in IDEA and enter mvn cle...