search
HomeWeb Front-endCSS TutorialSummary of CSS Common Properties Three

******* Common CSS properties *********

【margin】

margin Retrieve or set the extended margins on the four sides of the object

margin-top Retrieve or set the extended margins of the top edge of the object

margin-right Retrieve or set the extended margins on the right side of the object

margin-bottom Retrieve or set the extended margin of the bottom edge of the object

margin-left Retrieve or set the extended margin of the left side of the object

argin: Retrieves or sets the outer margins of the object's four sides.

If all four parameter values ​​are provided, they will be applied to the four sides in the order of upper, right, lower, and left.

If only one is provided, it will be used for all four sides.

If two are provided, the first one is for up and down, and the second one is for left and right.

If three are provided, the first one is for top, the second one is for left and right, and the third one is for bottom.

Inline objects can use this attribute to set the outer patches on the left and right sides; if you want to set the outer patches on the upper and lower sides, you must first make the object appear as block level or inline block level.

Extended margins are always transparent.

Some adjacent margins will merge, which we call margin folding:

General knowledge of margin folding:

Margin folding only Occurs on block-level elements;

The margin of a floating element does not collapse with any margin;

A block-level element that has the attribute overflow set and the value is not visible will not overlap with its children. The margin of the element is collapsed;

The margin of the absolutely positioned element does not collapse with any margin;

The margin of the root element does not collapse with any other margin;

auto: The value is set to the value of the opposite edge

: Use the length value to define the outer padding. Can be negative

: Use percentage to define outer padding. Can be negative

---------------------------------- --------------------------------------------------

****************************************** *************************************************** *********************

【padding】

padding Search Or set the internal padding on the four sides of the object

padding-top Retrieve or set the internal padding on the top edge of the object

padding-right Retrieve or set the internal padding on the right side of the object

padding-bottom Retrieve or set the internal padding of the bottom edge of the object

padding-left Retrieve or set the internal padding of the left side of the object

padding: Retrieve or set the object Internal margins on all four sides.

If all four parameter values ​​are provided, they will be applied to the four sides in the order of upper, right, lower, and left.

If only one is provided, it will be used for all four sides.

If two are provided, the first one is for up and down, and the second one is for left and right.

If three are provided, the first one is for top, the second one is for left and right, and the third one is for bottom.

Inline objects can use this attribute to set the inner patches on the left and right sides; if you want to set the inner patches on the upper and lower sides, you must first make the object appear as block level or inline block level.

: Use length value to define inner padding. Negative values ​​are not allowed

: Use percentage to define inner padding. Negative values ​​are not allowed

---------------------------------- --------------------------

************ *************************************************** *******************************************

【text】

text-transform Retrieve or set the case of the text in the object

white-space Set or retrieve the processing of spaces in the object Method

tab-size Retrieve or set the length of the tab character in the object

word-wrap Set or retrieve whether the line is broken when the content exceeds the boundary of the specified container

word -Bream settings or retrieved objects in the text in the text in the text

Text-Align Set or retrieve the level of content in the retrieval object

Text-Align-Last setting or retrieve a block in a block The last line (including the case where there is only one line of text in the block, which is both the first and last line)

                                                  or the alignment of the line that is forcibly interrupted

text-justify               or Retrieve the alignment used to adjust text within the object

WORD-SPACING Retrieval or Set the Smaller between the words in the objects, the maximum and best gap

Letter-Spacing retrieval or set the minimum, maximum and best gap

text-indent                                                                                                                                                      # row height. That is, the distance between the bottom of the font and the top of the inside of the font

------------------------- --------------------------

letter-spacing: Retrieve or set the spacing between characters in the object Minimum, maximum and optimal gaps.

This attribute adds the specified spacing after each letter (including each letter within the word);

letter-spacing cannot be applied to the beginning of a line and end;

normal: Default interval

: Specify the interval with a length value. Can be negative.

: Specify the interval in percentage. Can be negative.

----------------------------------------- --------------------------

line-height: Retrieve or set the line height of the object . That is, the distance between the bottom of the font and the top of the inside of the font.

Default value: normal

normal: Allow content to push or overflow the specified container boundaries.

: Use the length value to specify the line height. Can be negative.

: Use a percentage to specify the line height, and the percentage value is based on the height size of the font. Can be negative.

: Use the product factor to specify the row height. Can be negative.

----------------------------------------- -----------------------

text-align: Sets or retrieves the horizontal alignment of the content in the object.

The text of block-level elements is some stacked wireframes

To make text-align's justify alignment take effect, you need to insert spaces between Chinese characters, such as Space;

The last line of text in the block (including the case where there is only one line of text in the block, which is both the first and last line) and the line that is forcibly interrupted, need to use text to align both ends -align-last;

Under IE browser, if text-align-last is to take effect, text-align must be defined as justify;

The alignment effect of both ends of a single line becomes relatively simple:

li{overflow:hidden;width:200px;height:21px;text-align:justify;text-align-last:justify;}

li:after {display:inline-block;overflow:hidden;width:100%;height:0;content:'';}

left: Content is left aligned.

center: The content is centered.

right: The content is right aligned.

justify: Align the content on both ends.

start: The content is aligned to the starting boundary. (CSS3)

end: Content alignment end boundary. (CSS3)

: The string must be a single character, otherwise the declaration will be invalid. (CSS3)

match-parent: This value behaves the same as inherit, except that the start or end keyword inherited by this value is calculated against the parent's direction value. The calculated values ​​can be left and right. (CSS3)

start end: Specify start to align the first line and any forced interruption lines; end aligns all remaining lines and is not affected by text-align-last.

++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

A few points to note:

All major browsers support the justify attribute of text-align Value;

text-align does not process forcibly broken lines, nor does it process the last line in the block. In other words, if there is only one line of text in the block (the line is both the One line is also the last line), then just setting text-align:justify cannot align both ends of the line;

text-align-last is used to process the last line in the block and forcedly interrupted lines, so when you want to set the alignment of a single line of text at both ends, you need to use text-align-last;

Non-Firefox browsers must enable alignment at both ends. Spaces need to be inserted between the text, such as spaces (if there are only 2 Chinese characters in a line, Firefox also needs to insert spaces between them);

Chrome23, Safari5.1.7, Opera12.5 are still Text-align-last is not supported;

According to the above points, to achieve alignment of both ends of a single line, you can go in two directions:

Since all browsers support The justify attribute value of text-align does not fully support text-align-last. We can use pseudo objects to generate additional content for non-IE and IE7 and above browsers (IE7 and below browsers do not support pseudo objects, use text-align- last processing), place it on the second line and hide it. At this time, the first line of text (that is, the single line of text to be aligned) can be aligned using text-align:justify

Browsers that support text-align-last, such as IE and Firefox, use text-align-last processing, and browsers that do not support it use the above method;

So based on the current situation, use The first solution is relatively simple and can be easily compatible with IE5.5-10, Firefox, Chrome, Safari, Opera

++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++

text-align-last: Set or retrieve the last line in a block (including the case where there is only one line of text in the block, in which case it is both the first and last line)

                                                                                                                                                                                                  or the alignment of lines that are forcibly interrupted

 

If a line is also the first line in the block or the first line but is followed by a forced line break, unless it is displayed Specify text-align first line alignment (value 'start end'), otherwise text-align-last will override text-align;

If the auto value is specified, the content alignment will be based on text -align setting, unless text-align is set to justify;

As one of IE's private attributes, IE5.5 was the first to implement text-align-last, which was later adopted as a standard attribute by w3c;

IE7 and below browsers only implement the alignment of the last line in the block, and do not handle the alignment of forcibly interrupted lines. Starting from IE8, both forms of line alignment are supported;

Under IE browser, if text-align-last is to take effect, text-align must first be defined as justify;

auto: No special alignment.

left: The content is left aligned.

center: The content is centered.

right: The content is right aligned.

justify: Align the content on both ends.

start: The content is aligned to the starting boundary.

end: Content alignment end boundary.

----------------------------------------- ---------

text-indent: Retrieve or set the indent of the text in the object.

To use this property on an inline object, you must first make the object appear as block level or inline block level.

The hanging and each-line keywords follow the indentation value

div{text-indent:2em each-line;}

: Use the length value to specify the indentation of the text. Can be negative.

: Specifies the indentation of the text using percentages. Can be negative.

each-line: Define the indentation to be applied to the first line of the block container or the first line of each forced line break inside. Soft line breaks are not affected. (CSS3)

hanging: Reverse all indented lines.

----------------------------------------- -------------------------------------------------- -----------

text-transform: Retrieve or set the case of the text in the object.

none: No conversion

capitalize: Convert the first letter of each word to uppercase

uppercase: Convert each word to Uppercase

lowercase: Convert each word to lowercase

full-width: Convert all characters to fullwidth form. If a character does not have a corresponding fullwidth form, it will be left intact. This value is commonly used for typesetting ideographic symbols such as Latin characters and numbers.

----------------------------------------- -------------------------------------------------- ------------------

vertical-align: Sets or retrieves the vertical alignment of inline elements within the line box.

baseline: Align the content of the object that supports the valign feature to the baseline

sub: Vertically align the subscript of the text

super: Vertically align the text The superscript

top: Align the content of the object that supports the valign feature to the top of the object

text-top: Align the text of the object that supports the valign feature to the top of the object

middle: Align the content of an object that supports the valign feature to the middle of the object

bottom: Align the text of an object that supports the valign feature to the bottom of the object

text-bottom: Will support the valign feature Align the object's text to the top of the object

: Use a percentage to specify the offset from the baseline. Can be negative. The baseline for percentages is 0%.

: Use the length value to specify the offset from the baseline. Can be negative. The baseline is 0 for numeric values.

----------------------------------------- -------------------------------------------------- ------------

word-break: Set or retrieve the word-break behavior of the text within the object.

To solve the problem of preventing continuous meaningless long characters in the page from breaking the layout, break-all should be used;

As one of the private attributes of IE, IE5.5 It was the first to implement word-break, which was later adopted as a standard attribute by w3c;

normal: According to the text rules of Asian languages ​​and non-Asian languages, line breaks within words are allowed.

keep-all: Same as normal for all non-Asian languages. For Chinese, Korean, and Japanese, word breaks are not allowed. Good for non-Asian text that contains a small amount of Asian text.

break-all: This behavior is the same as normal in Asian languages. Breaks within any word of a line of non-Asian language text are also allowed. This value is suitable for Asian text that contains some non-Asian text, such as making consecutive English letters break lines.

-------------------------------------------------- ---------------

word-wrap: Sets or retrieves whether to break lines when the content exceeds the boundaries of the specified container.

normal: Allow content to push or overflow the specified container boundaries.

break-word: Content will break within boundaries. Line breaks are allowed within words if necessary.

----------------------------------------- ----------------------------

The above is the content of summary three of common CSS properties. Please pay attention to more related content. PHP Chinese website (www.php.cn)!


Statement
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
CSS Inclusion: Choosing the Right Method for Your ProjectCSS Inclusion: Choosing the Right Method for Your ProjectMay 16, 2025 am 12:02 AM

ThebestmethodforincludingCSSdependsonprojectsizeandcomplexity:1)Forlargerprojects,useexternalCSSforbettermaintainabilityandperformance.2)Forsmallerprojects,internalCSSissuitabletoavoidextraHTTPrequests.Alwaysconsidermaintainabilityandperformancewhenc

This Isn't Supposed to Happen: Troubleshooting the ImpossibleThis Isn't Supposed to Happen: Troubleshooting the ImpossibleMay 15, 2025 am 10:32 AM

What it looks like to troubleshoot one of those impossible issues that turns out to be something totally else you never thought of.

@keyframes vs CSS Transitions: What is the difference?@keyframes vs CSS Transitions: What is the difference?May 14, 2025 am 12:01 AM

@keyframesandCSSTransitionsdifferincomplexity:@keyframesallowsfordetailedanimationsequences,whileCSSTransitionshandlesimplestatechanges.UseCSSTransitionsforhovereffectslikebuttoncolorchanges,and@keyframesforintricateanimationslikerotatingspinners.

Using Pages CMS for Static Site Content ManagementUsing Pages CMS for Static Site Content ManagementMay 13, 2025 am 09:24 AM

I know, I know: there are a ton of content management system options available, and while I've tested several, none have really been the one, y'know? Weird pricing models, difficult customization, some even end up becoming a whole &

The Ultimate Guide to Linking CSS Files in HTMLThe Ultimate Guide to Linking CSS Files in HTMLMay 13, 2025 am 12:02 AM

Linking CSS files to HTML can be achieved by using elements in part of HTML. 1) Use tags to link local CSS files. 2) Multiple CSS files can be implemented by adding multiple tags. 3) External CSS files use absolute URL links, such as. 4) Ensure the correct use of file paths and CSS file loading order, and optimize performance can use CSS preprocessor to merge files.

CSS Flexbox vs Grid: a comprehensive reviewCSS Flexbox vs Grid: a comprehensive reviewMay 12, 2025 am 12:01 AM

Choosing Flexbox or Grid depends on the layout requirements: 1) Flexbox is suitable for one-dimensional layouts, such as navigation bar; 2) Grid is suitable for two-dimensional layouts, such as magazine layouts. The two can be used in the project to improve the layout effect.

How to Include CSS Files: Methods and Best PracticesHow to Include CSS Files: Methods and Best PracticesMay 11, 2025 am 12:02 AM

The best way to include CSS files is to use tags to introduce external CSS files in the HTML part. 1. Use tags to introduce external CSS files, such as. 2. For small adjustments, inline CSS can be used, but should be used with caution. 3. Large projects can use CSS preprocessors such as Sass or Less to import other CSS files through @import. 4. For performance, CSS files should be merged and CDN should be used, and compressed using tools such as CSSNano.

Flexbox vs Grid: should I learn them both?Flexbox vs Grid: should I learn them both?May 10, 2025 am 12:01 AM

Yes,youshouldlearnbothFlexboxandGrid.1)Flexboxisidealforone-dimensional,flexiblelayoutslikenavigationmenus.2)Gridexcelsintwo-dimensional,complexdesignssuchasmagazinelayouts.3)Combiningbothenhanceslayoutflexibilityandresponsiveness,allowingforstructur

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!