Home >Web Front-end >Front-end Q&A >what is in css
CSS (Cascading Style Sheets), cascading style sheets, is a language used to control the style and layout of web pages. It can define the appearance style and layout of text, pictures, background colors, fonts, spacing, borders, shadows, animations and other elements to make web pages more beautiful, easier to read and interact with, and improve user experience.
CSS was originally proposed by W3C in 1996 as an auxiliary language for markup languages such as HTML and XML. Through CSS, we can separate web page content and style, making the web page structure clearer and simpler. At the same time, styles can also be shared by multiple web pages, saving development and maintenance costs.
The main function of CSS is to define the style and layout of web pages. Common CSS style attributes include the following:
1. Font style
You can set the size, color, weight, font series and other attributes of the font, for example:
font-size:20px; /Set the font size to 20 pixels/
color:red; /The font color is red/
font- weight:bold; /Font bold/
font-family:Arial, sans-serif; /Set the font family to Arial or sans-serif/
2. Background style
You can set the background color, picture, repetition method, horizontal and vertical alignment and other attributes, for example:
background-color:#f5f5f5; / Set the background color to light gray/
background-image:url("background.png"); /Set the background image/
background-repeat: no-repeat; /Do not display background images repeatedly/
background-position:center top; /Horizontally centered, top aligned/
3 .Border style
You can set the style, color, width and other properties of the border, for example:
border-style:solid; /Set the border style to solid/
border-color:#ccc; /Set the border color to gray/
border-width:1px; /Set the border width to 1 pixel /
4. Box model
You can control the size, inner margin and outer margin of the element, for example:
width:200px; /Set the element width to 200 pixels/
height:100px; /Set the element height to 100 pixels/
padding:10px; /Set the padding to 10 Pixel/
margin:20px; /Set the outer margin to 20 pixels/
5. Positioning and layout
You can control the elements Position and arrangement, for example:
position:absolute; /Absolute positioning/
top:30px; /30 pixels from the top/
left:50%; /Horizontally centered/
display:flex; /Flexible box layout/
justify- content:center; /Horizontal center alignment/
The above are just a small part of the common style properties of CSS. CSS can also achieve numerous interactive effects, such as hover, click, gradient, Rotate, scale, animate, etc. At the same time, CSS also supports media queries, which can provide different users with the best browsing experience according to different devices and screen sizes.
In general, CSS is an indispensable part of web design. It can add color and age to web pages, improve user experience, and make web pages more attractive and competitive.
The above is the detailed content of what is in css. For more information, please follow other related articles on the PHP Chinese website!