search
HomeWeb Front-endCSS TutorialChapter 4 CSS for Color Background

Chapter 4 CSS for Color Background

Dec 19, 2016 pm 04:06 PM
css

The main function of this chapter CSS

After introducing the declaration and application methods and some features in the previous chapters, starting from this chapter, we will officially enter the introduction of the CSS command! This chapter has two introduction topics. The first part introduces the CSS of color and background properties. Its main function is to set the properties of style settings such as foreground color, background color and background graphics of elements; and the second part introduces the properties of color and background properties of CSS. Part of the introduction to you is the CSS instructions used to control the position of placed elements.

Color background CSS command

color Set the foreground color Support: IE3, IE4, NC4 Applicable: all elements Possible values: To set the color, please refer to Chapter 1 Color Instructions for use Default: Depends on browser Inheritance: Yes General example: SPAN { color : BLUE } Coaxial example: background-color Set background color support : IE4, NC4 Applicable: All elements Possible values: To set the color, please refer to the relevant instructions on color use in Chapter 1 transparent. Make the background of the parent element (color or pattern) transparent. Default value: transparent Inheritance: No general example: BODY { background-color : BLUE } Coaxial example: background-image Set background graphics Support: IE4, NC4 Applicable: all elements Possible values: < ;url> To set the image URL, please refer to the relevant instructions on URL representation in Chapter 1 none Do not use the background pattern Default value: transparent Inheritance: None General example: BODY { background-image : URL("http://yourweb /path/file_name") }Coaxial example: background-repeat Set background repeat support: IE4, NC4 Applicable to: All elements Possible values: repeat Repeat the background graphic to fill the page repeat-x Repeat the background graphic in the horizontal direction repeat-y Repeat the background graphic in the vertical direction no-repeat Do not display the background graphic repeatedly Default value: repeat Inheritance: None General example: BODY { background-repeat : repeat-x } Coaxial example: background-attachment Set background attachment support: IE4, NC4 Applicable: all elements Possible values: scroll The background graphic scrolls with the scroll fixed The background graphic scrolls with the scroll (watermark) Default value: scroll Inheritance: None General example: BODY { background-attachment : fixed } Coaxial example: background-position Set the background position Support: IE4, NC4 Applicable: block elements Possible values: % position Value: 0% 0% Inheritance: None General example: BODY { background- position : 100% 50% } Coaxial example: background Comprehensive setting background Property support: IE3, IE4, NC4 Applicable: all elements Possible values: background-color Set the background color background-image Set the background image background-repeat Set the background repeat background-attachment Set the background attachment background-position Set the background position Default: None Inheritance: None General example: BODY { BLUE url(image/gif) repeat-x fixed center } Coaxial example:

Position placement command

float Set the floating property (mostly used when text wraps around images) Support: IE4, NC4 Applicable to: block elements or graphics Possible values: left element to the left, text around its right right element to the right, text around its left none or Default method to display default value: none Inheritance: none General example: DIV { float : right } Coaxial example:

clear Set clear properties (set whether to allow floating The existence of the element) Support: IE4 Applicable: block elements or graphics Possible values: both If there are floating elements on both sides, the element will be moved below the floating element left If there is a floating element on the left, the element will be moved below the floating element right If there is a floating element on the right If there is a floating element, the element will be moved below the floating element none to display the default value in the default method: none Inheritance: none General example: DIV { clear : right } Coaxial example:
width Setting width supports: IE4, NC4 Applicable: block elements or graphics Possible values: Length unit, please refer to the relevant instructions on basic units in Chapter 1 Percentage, based on the width of the parent element Baseline auto automatically changes size at a fixed ratio Default value: auto Inheritance: None General example: DIV { width: 300pt } Coaxial example:
height Setting height support: IE4, NC4 is applicable to: block elements or graphics. Possible values: length unit, please refer to the related instructions of basic units in Chapter 1. Percentage, based on the width of the parent element, auto automatically changes the size at a fixed ratio. Default value :auto Inheritance: None General example: DIV { height : 300pt } Coaxial example:
position Set position Support: IE4, NC4 Applicable: block element Possible values: absolute Based on the parent element, it is placed at a specific position relative. Based on the adjacent element, it is placed at a specific position. static. The default position is based on the position of the element in the source code. Default value: absolute Inheritance: None General example: DIV { position : static } Coaxial example:
top Set the top position Support: IE4, NC4 Applicable: Block element Possible values: Length unit, please refer to Chapter Chapter Description of basic units Percentage, based on the width of the parent element auto displays the default value in the normal way: auto inheritance: none General example: DIV { top : 30pt } Coaxial example:
left Setting the left end position supports: IE4, NC4 Applicable: Block element Possible values: Length unit, please refer to the relevant description of the basic unit in Chapter 1 Percent, to The width of the parent element is based on auto and the default value is displayed in the normal way: auto Inheritance: None General example: DIV { left : 30pt } Coaxial example:
clip Set clipping (set Determine the shape and size of a certain area, transparent outside the area) Support: IE4, NC4 Applicable: block element Possible values: rect (top, right, bottom, left) Set the length of the top, right, bottom and left of the rectangle, and it will automatically compare The side length is generally written as rect(0, length, length, 0) and cannot be written as rect(0, 0, length, length). All four values ​​can be "auto" instead of auto to display the default value in the normal way: auto inheritance : None General example: DIV { clip : rect(0,100px,50px,0) } Coaxial example:
overflow Setting overflow processing ( Controls the display method when the content of an element exceeds the size of the element) Supported: IE4 Applicable: block elements Possible values: visible elements will not be displayed according to the set size, but all content hidden that exceeds the set size of the element will be visible copies will be hidden and will not be displayed scroll If necessary, a scroll will appear so that the user can see all the content auto Display in the default way Default value: auto Inheritance: None General example: DIV { overflow: scroll } Coaxial example :
visibility Set visibility Support: IE4, NC4 Applicable: all elements Possible values: visible Set the element to be displayed hidden Set the element not to be displayed, but still occupy space inherit Determine the default value based on the visibility of the parent element: inherit inheritance: none General example: DIV { visibility : hidden } Coaxial example:
z-index Set the Z-axis parameter ( Three-dimensional space) Support: IE4, NC4 Applicable: Block element Possible values: decimal value, elements with large values ​​will appear above elements with small values ​​auto When the element position is repeated, the original code is written in The following elements will appear above the previous elements. Default value: auto Inheritance: None General example: DIV { z-index : 3 } Coaxial example:

The above is the content of the CSS of color background in Chapter 4. For more related content, 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
@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.

CSS Animations: Is it hard to create them?CSS Animations: Is it hard to create them?May 09, 2025 am 12:03 AM

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

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

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software