search
HomeWeb Front-endCSS TutorialCSS Practical Tutorial (2)

CSS Practical Tutorial (2)

Dec 17, 2016 am 11:39 AM
css tutorial

Seven. Controlling the style of text

Controlling the style of text includes two parts: text case and text modification.

1. Text case

Text case allows web designers to avoid having to complete the case of text when entering text. Instead, they can set the case of partial text as needed after inputting.

The basic format is as follows:

text-transform: Parameter

Parameter value range:

·uppercase: All text is displayed in uppercase

·lowercase: All text is displayed in lowercase

·capitalize: The first letter of each word is capitalized Display

·none: Do not inherit the text transformation parameters of the parent

Note: Inheritance means that HTML identifiers will be inherited for parameters that contain their own identifiers.

2. Text modification

The main purpose of text modification is to change the underline when the browser displays text links.

The basic format is as follows:

text-decoration: parameter

Parameter value range:

·underline: underline the text

·overline: underline the text

·line-through: underline the text Strikethrough

·blink: Make the text blink

·none: Do not display any of the above effects

8. Control the style of text

The style of controlling text includes six parts: word distance, letter distance, text line spacing, text horizontal alignment, text vertical alignment, and text indentation.

1. Word spacing

Word spacing refers to the distance between each word in English, excluding Chinese characters.

The basic format is as follows:

Word-spacing: Spacing distance

The value of spacing distance: points, em, pixels, in, cm, mm, pc, ex, normal, etc.

2. Letter spacing

Letter spacing refers to the distance between English letters. The functions, usage, and parameter settings are very similar to word spacing.

The basic format is as follows:

letter-spacing: letter spacing

3. Leading spacing

Leading spacing refers to the vertical distance between the upper and lower baselines. Generally speaking, in English five-line exercise books, the third horizontal line from top to bottom is what the computer considers to be the baseline of that line.

The basic format is as follows:

line-height: distance between lines

Value of distance between lines:

·Number without unit: 1 is the base, equivalent to 100% of the proportional relationship

·With length unit Number: subject to specific units

·Proportional relationship

Note: If the text font is large and the line spacing is relatively small, the upper and lower lines of text may overlap each other.

4. Text horizontal alignment

Text horizontal alignment can control the horizontal alignment of text, and it not only refers to text content, but also includes setting the alignment of pictures and video materials.

The basic format is as follows:

text-align: parameter

Value of parameter:

·left: left alignment

·right: right alignment

·center: center alignment

·justify: relative left and right alignment

But it should be noted that text-alight is a block-level attribute and can only be used in identifiers such as , , , ~.

5. Vertical alignment of text

The vertical alignment of text should be relative to the position of the text parent, not the vertical alignment of text on the web page. For example, if there is a section of text in a table cell, then setting the vertical centering of this text is measured against the cell. That is to say, the text will be displayed in the center of the cell, not the center of the entire web page.

The basic format is as follows:

vertical-align: parameter

parameter value:

·top: top alignment

·bottom: bottom alignment

·text-top: relative text top alignment

·text-bottom : Relative to text bottom alignment

·baseline: baseline alignment

·middle: center alignment

·sub: displayed in the form of subscript

·super: displayed in the form of superscript

6. Text indent

Text indent allows text to be displayed in a narrower area than the default value. It is mainly used to indent the first line of Chinese style, or to create an indent format for large paragraphs of quoted text and notes.

The basic format is as follows:

text-indent: Indent distance

Indent distance value:

·Numbers with length units

·Proportional relationship

But it should be noted that when using proportional relationships , some people may think that the default proportion of the browser is relative to the width of the paragraph. In fact, this is not the case. The entire browser window is the default reference of the browser.

In addition, text-indent is a block-level attribute and can only be used in identifiers such as , , , ~.
Nine. Control the style of color and background

The style of controlling color and background includes six parts: color attribute, background color, background image, background image repetition, background image fixed, and background positioning.

1. The basic format of the color attribute

is as follows:

color: parameter

Color parameter value range:

·Represented by RGB value

·Represented by hexadecimal (hex) color value

·In English of the default color Name representation

It is undoubtedly the most convenient to use the English name of the default color, but because there are too few predefined color types, more web designers prefer to use the RGB method. The RGB method has many benefits. Not only can it accurately represent colors in digital form, but it is also the default specification used in many image production software (such as photoshop). This lays a solid foundation for better integration of pictures and web pages. .

2. Background color

In HTML, there is only one way to add a background color to an object, and that is to first make a table, set the background color in the table, and then put the object into the cell. This is more troublesome. Not only does it require a lot of code, but it also takes some trouble with the size and positioning of the table. Now it's easy to do it directly with CSS, and the object range is very wide, it can be a piece of text, or just a word or a letter.

The basic format is as follows:

background-color: Parameter

The parameter value is the same as the color attribute.

3. The basic format of the background image

is as follows:

background-image: url(URL)

URL is the storage path of the background image. If "none" is used instead of the background image storage path, nothing will be displayed.

4. Background image duplication

Background image duplication controls whether the background image is tiled or not. In other words, combined with the control of background positioning, a background image can be displayed separately somewhere on the web page.

The basic format is as follows:

background-repeat: Parameter

Parameter value range:

·no-repeat: Do not repeat the tiled background image

·repeat-x: Make the image tiled only in the horizontal direction

·repeat-y: Make the image tile only in the vertical direction

If you do not specify the background image repeat attribute, the browser defaults to the background image being tiled in both horizontal and vertical directions.

5. Background image fixed

Background image fixed controls whether the background image scrolls with the scrolling of the web page. If you do not set the background image fixed attribute, the browser's default background image will scroll with the scrolling of the web page. In order to prevent overly fancy background images from damaging the viewer's eyesight when scrolling, you can unbundle the background image and text content, which should be bundled with the browser window.

The basic format is as follows:

background-attachment: Parameter

Parameter value range:

·fixed: When the webpage scrolls, the background image is fixed relative to the browser window

·scroll: The webpage scrolls When, the background image scrolls together relative to the browser window

6. Background positioning

Background positioning is used to control the position of the background image displayed on the web page.

The basic format is as follows:

background-position: Parameter table

Parameter value range:

·Numeric parameter with length unit

·top: top alignment relative to the foreground object

·bottom: bottom alignment relative to the foreground object

·left: Aligned to the left relative to the foreground object

·right: Aligned to the right relative to the foreground object

·center: Aligned to the center of the foreground object

·Proportion relationship

If the center in the parameter is used in front of another parameter, It means horizontal centering; if used after another parameter, it means vertical centering.

Ten. Control the style of the list

List is a very useful display method in HTML. It can neatly arrange related parallel content vertically, making the web page look neat and professional, and giving viewers a clear feeling.

The style sheet adds some functions to the list. The style of the control list includes three parts: list style, graphic symbol, and list position.

1. List symbols

List symbols refer to the symbols displayed in front of each list item.

The basic format is as follows:

list-style-type: parameter

Parameter value range:

·disc: circle

·circle: hollow circle

·square: square

·decimal: decimal number

·lower-roman: lowercase Roman numerals

·upper-roman: uppercase Roman numerals

·lower-alpha: lowercase Greek letters

·upper-alpha: uppercase Greek letters

·none: unsigned display

parameters disc in is the default option.

2. Graphic symbols

Graphic symbols mean that the bullet points of the original list can be replaced by graphics.

The basic format is as follows:

list-style-image: URL

URL is the address of the graphic file used to replace bullets, and you can use relative addresses or absolute addresses.

3. List Position

List Position describes where the list is displayed.

The basic format is as follows:

list-style-position: parameter

Parameter value range:

·inside: displayed inside the BOX model

·outside: displayed outside the BOX model

A new one appears here Concept: BOX model. BOX refers to a container that contains objects to which style rules are applied. The detailed introduction will be given later.

Eleven. Control the style of the user interface

On a web page, the mouse is usually in the shape of an arrow, becomes a hand shape when pointing to a link, and becomes an hourglass shape when waiting for the web page to be downloaded... This seems to be a convention. Although this design allows us to know the current status of the browser or what it can do, it seems that it cannot fully meet our needs. Take a link as an example. It can point to a help file, or it can go forward one page or back one page. For so many functions, the same hand-shaped mouse alone cannot explain the problem. Fortunately, CSS provides up to 13 mouse shapes for us to choose from.

The basic format is as follows:

cursor: mouse shape parameters

CSS mouse shape parameter table:

CSS code

Mouse shape

style="cursor:hand"

Hand shape

style="cursor:crosshair"

Cross shape

style="cursor:text"

Text shape

style="cursor:wait"

Hourglass shape

style="cursor:move"

Cross arrow shape

style="cursor :help"

question mark shape

style="cursor:e-resize"

right arrow shape

style="cursor:n-resize"

up arrow shape

style="cursor:nw-resize"

Upper left arrow shape

style="cursor:w-resize"

Left arrow shape

style="cursor:s-resize"

Down arrow shape

style="cursor:se-resize"

Lower right arrow shape

style="cursor:sw-resize"

Lower left arrow shape

The above is the content of CSS practical tutorial (2). For more related articles, please pay attention to the 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
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

Orbital Mechanics (or How I Optimized a CSS Keyframes Animation)Orbital Mechanics (or How I Optimized a CSS Keyframes Animation)May 09, 2025 am 09:57 AM

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.

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 Article

Hot Tools

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.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.