Table of Contents
display property:block/inline/none
none: Object does not float
visible: Content is not cut Do not add scroll bars
inherit: Inherit the visibility of the previous parent object
jpg: Transparent is supported
Home Web Front-end CSS Tutorial Several properties of CSS display, float, clear, overflow, visibility

Several properties of CSS display, float, clear, overflow, visibility

Jun 28, 2017 am 11:32 AM
clear display float

http://colobu.com/2014/08/28/CSS-display-float-clear-overflow-visibility/

display property:block/inline/none

display :block (the function is to display the row attribute label as a block attribute label, and the width and height can be set);
display: inline (the function is to display the block attribute label as a row attribute label, and the width and height cannot be set for the block attribute label at this time) ; The difference between display:none and display:none is that the latter will not occupy that position, and the next element will directly cover it, while the former will occupy that layout, but does not display the content and is blank; and when downloading, display:none will Elements that are not displayed will not be downloaded, but visibility: hidden will download elements that are not displayed;

float (floating, still subject to document flow restrictions) can be set after the row label float Its width and height

float: none/left/right

none: Object does not float

left: Left float

right: Right float

clear(
Clear floats

)

clear: both/none/left/rightnone: Allow floating objects on both sides

both: No floating objects allowed

left: Not allowed There are floating objects on the left
right: Floating objects on the right are not allowed

overflow (overflow)

overflow: visible/auto/hidden/scroll

visible: Content is not cut Do not add scroll bars

auto: Default properties

hidden: Hide beyond content
scroll: Always display scroll bars

visibility(visible)

visibility: inherit/ visible/hidden

inherit: Inherit the visibility of the previous parent object

visible: Object visible

hidden: Object hidden

Differences in several image formats:

gif: Translucent is not supported

jpg: Transparent is supported

png: Transparent is partially supported and requires additional processing


==============

http://www.studyofnet.com/news/398.html

1. Block-level elements: block element

Every By default, block-level elements occupy one row of height. Once a block-level element is added to a row, other elements cannot be added (except after float). When two block-level elements are edited continuously, they will automatically wrap and display on the page. Block-level elements can generally nest block-level elements or inline elements;

Block-level elements generally appear as containers to organize structures, but this is not always the case. Some block-level elements, such as
, can only contain block-level elements. Other block-level elements can contain line-level elements such as

. Others can contain both block-level and line-level elements.

p is the most commonly used block-level element, and the display:block element style is all block-level elements. They are always expressed in the form of a block, and are arranged vertically in sequence with the sibling blocks of the same level, filling up the left and right sides.

2. Inline element: inline element

is also called

inline Element

, inline elements, etc.; inline elements are generally based on basic elements at the semantic level and can only accommodate text or other inline elements. The common inline element "a" is common. For example, SPAN elements, IFRAME elements and element style display: inline are all inline elements. For example, elements such as text are arranged horizontally between letters and automatically wrap to the right end.

3. Characteristics of block elements

① Always on a new line Start;


②, height, line height, margins and padding can all be controlled;


③, the width defaults to 100% of its container, Unless you set a width.


④. It can accommodate inline elements and other block elements



4. Characteristics of inline elements

①, and other elements are on the same line;


②, height, line height, outer margins and inner margins cannot be changed;


③. The width is the width of its text or picture and cannot be changed.

④. Inline elements can only accommodate text or other inline elements


For inline elements, please note the following

    Setting the width width is invalid.
  • Setting the height height is invalid and can be set through line-height.
  • #Setting margin Only left and right margins are valid, upper and lower margins are invalid.
  • # Setting padding is only valid for left and right padding, but not for top and bottom. Note that the scope of the element is increased, but the content around the element is not affected.


5. Common block elements

address – address
  • blockquote – Block quote

  • center – Center alignment block

  • dir – Directory listing

  • p – Commonly used block level, also the main tag of CSS layout

  • dl – Definition list

  • fieldset – form control group

  • form – interactive form

  • h1 – title

  • h2 – Subtitle

  • h3 – Level 3 heading

  • h4 – Level 4 heading

  • ##h5 – Level 5 heading

  • h6 – Level 6 heading

  • hr – Horizontal separator line

  • isindex – input prompt

  • menu – menu list

  • noframes – frames optional content, (this block is displayed for browsers that do not support frames Content

  • noscript – optional script content (displayed for browsers that do not support script)

  • ol – ordered form

  • p – paragraph

  • pre – formatted text

  • table – table

  • ul – Unordered list

6. Common inline elements

  • a – anchor

  • abbr – abbreviation

  • acronym – first letter

  • b – bold (not recommended)

  • bdo – bidi override

  • big – big font

  • br – line break

  • cite – quote

  • code – computer code (when citing source code Required)

  • dfn – Define fields

  • em – Emphasis

  • font – Font setting (Not recommended)

  • i – italic

  • #img – image

  • input – input box

  • kbd – Define keyboard text

  • label – Table label

  • q – Short quote

  • s – dash (not recommended)

  • samp – definition sample computer code

  • select – item selection

  • small – small font text

  • span – commonly used inline container, defining blocks within text

  • strike – strikethrough

  • strong – bold emphasis

  • sub – subscript

  • sup – superscript

  • textarea – multi-line text input box

  • tt – telex text

  • u – Underline

7. What is the difference between inline elements and block-level elements?

Difference 1:

Block level: Block level elements will occupy one line by default. Automatically fill the width of its parent element

Inline:Inline elements will not occupy a row, and adjacent inline elements will be arranged on the same line. Its width changes with the content.

Difference 2:

Block level: Block level elements can set width and height

Inline: The width and height of inline elements cannot be set

Difference three:

Block level: Block-level elements can be set with margin and padding

Inline: Margin-left; margin-right; padding-left; padding- right;can take effect. But the vertical margin-bottom; margin-top; padding-top; padding-bottom; does not take effect.

Difference four:

Block level: display:block;

Inline :display:inline;

You can switch between block-level elements and inline elements by modifying the display attribute



The above is the detailed content of Several properties of CSS display, float, clear, overflow, visibility. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Fujifilm X-M5 price expectations rise as leaked selfie display adds complexity to the formerly affordable camera line Fujifilm X-M5 price expectations rise as leaked selfie display adds complexity to the formerly affordable camera line Sep 07, 2024 am 09:34 AM

Fujifilm fans were recently very excited at the prospect of the X-T50, since it presented a relaunch of the budget-oriented Fujifilm X-T30 II that had become quite popular in the sub-$1,000 APS-C category. Unfortunately, as the Fujifilm X-T50's launc

Clear console output using Console.Clear function in C# Clear console output using Console.Clear function in C# Nov 18, 2023 am 11:00 AM

Use the Console.Clear function in C# to clear the console output. In C# console applications, we often need to clear the output information in the console in order to display new content or provide a better user experience. C# provides the Console.Clear function to implement this function, which can clear the output in the console and make the interface blank again. The calling format of the Console.Clear function is as follows: Console.Clear(); This function does not require any input

What is the maximum value of float? What is the maximum value of float? Oct 11, 2023 pm 05:54 PM

Maximum value of float: 1. In C language, the maximum value of float is 3.40282347e+38. According to the IEEE 754 standard, the maximum exponent of the float type is 127, and the number of digits of the mantissa is 23. In this way, the maximum floating point number is 3.40282347 e+38; 2. In the Java language, the maximum float value is 3.4028235E+38; 3. In the Python language, the maximum float value is 1.7976931348623157e+308.

Apple Studio Display's power cord is detachable, but requires special tools Apple Studio Display's power cord is detachable, but requires special tools May 17, 2023 pm 03:05 PM

Apple Studio Display is now officially available in stores, and many customers around the world have purchased the product. Unlike the ProDisplayXDR, the StudioDisplay has a unique power connector that appears to be non-removable. It turns out that the cable is removable, but you'll need a special tool to remove it. Apple says on its website that the Studio Display's power cord is not detachable -- and many users think so. That's because removing the cable with your hands seems impossible, but luckily the cable can be detached from the monitor. , Apple has a special tool for extracting information from its new StudioDispl

Comparison: Apple Studio Display vs Samsung Smart Monitor M8 Comparison: Apple Studio Display vs Samsung Smart Monitor M8 May 11, 2023 pm 10:46 PM

Samsung Smart Display M8 vs. Apple Studio Display: Design and Size Since its launch, the Apple Studio Display has been compared to the iMac, consisting of a relatively thin panel on a relatively simple L-shaped stand. It's a well-known and well-loved aesthetic, and Samsung seems to have borrowed it for its presentation. The Samsung SmartMonitor M8 uses the same idea of ​​a thin screen on a stand that looks very similar. Some minor elements are different, such as the small section in the lower left corner that sticks out a bit and the Samsung's chin is very thin, but they seem to be close in terms of basic design. Samsung seems to have taken a lot of inspiration from the 24-inch iMac. Apple's display is smaller than Samsung's

Samsung: New, large display based on E Ink technology displays colors and communicates wirelessly Samsung: New, large display based on E Ink technology displays colors and communicates wirelessly Jun 19, 2024 pm 03:37 PM

We frequently report on devices based on displays with electronic ink, such as e-readers. The technology offers a number of advantages: it can be read in bright environments without a backlight, and it only requires power when switching without light

Boot Camp updated to support Apple Studio Display Boot Camp updated to support Apple Studio Display May 20, 2023 pm 11:34 PM

IntelMac users running Windows on a Mac can now update their drivers in BootCamp to support Apple's StudioDisplay. Apple regularly updates BootCamp to introduce support for new hardware, as well as typical compatibility and performance improvements. In the March software update, Apple has enabled BootCamp to work with the new StudioDisplay. The update that brings BootCamp to version 6.1.17 introduces two key support elements. First, it adds compatibility with StudioDisplay, ensuring

display what does it mean display what does it mean Oct 26, 2023 am 11:50 AM

Display usually refers to the operation or function of displaying data, information or results to the user in some way or outputting it to a screen or other device. Specific meaning: 1. In the command line interface (CLI), display may refer to outputting data in text, tables or other formats to the terminal window for users to view or analyze; 2. In the graphical user interface (GUI), Display may refer to displaying images, text, charts and other content on the application window or interface for user interaction or browsing, etc.

See all articles