background Detailed explanation of usage:
1, background-color AttributeSet the background color of the element
Possible Value
color_name Specifies that the color value is the background color of the color name (such as red)
hex_number Specifies that the color value is a hexadecimal value Background color (such as #ff0000)
rgb_number Specifies that the color value is the background color of the rgb code (such as rgb(255,0,0)
transparent The default background color is transparent
2, background-image The attribute sets the background of the elementImage
Possible values
Single background image: background-image:url(a.png)
Multiple background images: background-image:url(a.png),url(b.png)
Linear Gradient: background-image:-webkit (-repeating)-linear-gradient(direction, color value in pixels or percentage, color value in pixels or percentage...)
Direction :left, right,top,bottom,90deg,180deg
Color value pixels or percentage: yellow 10%, transparent 4px, rgb(0, 0,0) 2px
Radial gradient: background-image:-webkit(-repeating)-radial-gradient([
-position>: The default is center
’ ‐ ’ s ’ s ’s ’ s ’ s ’ s , to cover
3,
background-sizeattributes are used to reset the size of the background image contain: shrink the background image to fit the label element
cover: The background image is enlarged and extended to the entire label element size
Pixels: Indicates the size of the background image scaling
Percentage: The percentage is based on the size of the content label element to scale the size of the image
4,
background-positionThe attribute is used to set the background image position Possible values: left, right, top, bottom, center, pixels, percentage
5 ,
background-repeatattribute is used to set the background image position Possible values: repeat,repeat-x,repeat-y,no-repeat,space (will not be cropped or resized ), round (will not be cropped but will change the image size)
6,
background-attachmentattributes are used to set whether the background image can be scrolled Possible values: scroll, fixed
7,
background-clipattributes are used to specify the drawing area of the background Possible values: b
order-box,padding-box,content-box8,
background-originattributes are used to specify the position relative to which the background-position attribute is positioned Possible Value: border-box, padding-box, content-box
Extension: draw square
html code
<p>使用背景绘制方格,使每个文字都在方格里,效果图如下。</p>
css code
p { width: 300px; height: 300px; border-left: 3px solid pink; border-top: 3px solid pink; background-image: -webkit-linear-gradient(180deg, pink 3px, transparent 3px) , -webkit-linear-gradient(90deg, pink 3px, transparent 3px); background-size: 30px; line-height: 30px; font-size:25px; letter-spacing: 5px; }
result
Use the background to draw a square grid so that each text is in the square grid. The rendering is as follows.
The above is the detailed content of Detailed explanation of the background attribute of css style. For more information, please follow other related articles on the PHP Chinese website!

In this week's roundup: Firefox gains locksmith-like powers, Samsung's Galaxy Store starts supporting Progressive Web Apps, CSS Subgrid is shipping in Firefox

In this week's roundup: Internet Explorer finds its way into Edge, Google Search Console touts a new speed report, and Firefox gives Facebook's notification

You’re probably already at least a little familiar with CSS variables. If not, here’s a two-second overview: they are really called custom properties, you set

Building websites is programming. Writing HTML and CSS is programming. I am a programmer, and if you're here, reading CSS-Tricks, chances are you're a

Here's what I'd like you to know upfront: this is a hard problem. If you've landed here because you're hoping to be pointed at a tool you can run that tells

Picture-in-Picture made its first appearance on the web in the Safari browser with the release of macOS Sierra in 2016. It made it possible for a user to pop

Gatsby does a great job processing and handling images. For example, it helps you save time with image optimization because you don’t have to manually

I learned something about percentage-based (%) padding today that I had totally wrong in my head! I always thought that percentage padding was based on the


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools