Home Web Front-end CSS Tutorial Experience summary of CSS style sheet planning and management_Experience exchange

Experience summary of CSS style sheet planning and management_Experience exchange

May 16, 2016 pm 12:07 PM

It has been more than a year since I completely abandoned table layout and used xhtml CSS to build websites. After more than a year of practice, I have accumulated a certain amount of experience. Now I am writing this article to summarize it. There is a key issue in the process of using xhtml CSS to build a website: the planning and management of the website's CSS style sheet.

My evolution history of CSS management

When I first used CSS to control website styles, I didn’t know anything about CSS management planning. The CSS I wrote was basically as needed. , add it at any time, and I didn’t think there was anything wrong with it at first, but then more and more were added, and the changes became more and more messy. Although there were some comments, in the end it still gave me a headache just looking at it. At that time, all the CSS of a website was in one file, without planning, and the ordering was not very regular. So I could only find the name of the class in the HTML page, and then search for what I wanted among thousands of lines of CSS code. that.

After a while, after thinking and summarizing, I made a preliminary plan for the CSS style sheet of the site. Three areas are initially divided into the style sheet:

Example Source Code [www.52css.com]
base style sheet
layout style sheet
class style sheet
Wherein " "base style sheet" is used to describe some common things, such as global body, a style, etc.; "layout style sheet" is used to describe a unique id layout, which belongs to the frame layout of the entire page; "class style sheet" " is used to describe the styles of the remaining classes. These styles are divided into reusable styles and styles that usually only appear once or a few times on a special page.

Layout according to this method does improve a lot of efficiency, but this method is only suitable for small and medium-sized websites. The application on large websites is still a bit thin, at least when multiple people collaborate, it cannot achieve the best results. Best efficiency. So there is a relatively complete CSS management planning model summarized below.

More complete CSS style sheet management model

Step1: Individuals or teams need to draw the layout of the main pages hierarchically using a DIV diagram. This DIV diagram is the basis for the design prototype. On the page, mark out the ID names and class names used by the main modules in the page to facilitate the creation of maintenance documents for future modifications and upgrades.

Step2: Divide the CSS structure and establish global css and each module css. Reference the global css in the html page, and reference the css of each module in the global css.

Example Source Code [www.52css.com]
Create global.css as global css, and define global styles such as "* { … } body { … }" in the global css.
Introduce module css through "@import url("xxx.css");" in the global style.
Regarding the division of module CSS, I prefer the CSS division method similar to that in wordpress. Generally, it is divided by a structure similar to the following:

Example Source Code [www.52css.com]
layout. css /* Entire site layout */
public.css /* Public combination style */
header.css /* Page header area style */
sidebar.css /* Sidebar area style * /
main.css /* Main area style */
footer.css /* Bottom area style */
index.css /* Home page area-specific style */
form.css /* Form Class style */
Explain that layout.css is responsible for the layout of the entire website, such as the basic position and style design of #header, #footer and other layouts; public.css is responsible for some common style definitions, because class can be used in a class =”navbar font12px” This method uses the space separation method to apply multiple class styles, so you can define some common classes that are commonly used or need to be modified under special circumstances to facilitate local fine-tuning; header.css, sidebar.css, Modules such as footer.css are css style sheets corresponding to the header, sidebar, and bottom modules. Modules can be added or deleted according to the specific needs of the website; index.css is the css for some unique elements of the homepage. Because of the particularity of the homepage, we When designing CSS, special treatment is usually given to the homepage. Generally, the homepage is the most complex page in CSS. It is necessary to classify and place the unique CSS elements of the homepage. You can also introduce index.css without @import. Put it separately for reference on the homepage; form.css is the style sheet of the form element. Although the form is not difficult, it is still troublesome to control. Put it separately in a css file for easy control. Of course, you can also use other similar elements. Deal with it this way.

Step3: Write styles in each style sheet file.​

Statement of this Website
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Working With GraphQL Caching Working With GraphQL Caching Mar 19, 2025 am 09:36 AM

If you’ve recently started working with GraphQL, or reviewed its pros and cons, you’ve no doubt heard things like “GraphQL doesn’t support caching” or

Making Your First Custom Svelte Transition Making Your First Custom Svelte Transition Mar 15, 2025 am 11:08 AM

The Svelte transition API provides a way to animate components when they enter or leave the document, including custom Svelte transitions.

Show, Don't Tell Show, Don't Tell Mar 16, 2025 am 11:49 AM

How much time do you spend designing the content presentation for your websites? When you write a new blog post or create a new page, are you thinking about

Building an Ethereum app using Redwood.js and Fauna Building an Ethereum app using Redwood.js and Fauna Mar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

What the Heck Are npm Commands? What the Heck Are npm Commands? Mar 15, 2025 am 11:36 AM

npm commands run various tasks for you, either as a one-off or a continuously running process for things like starting a server or compiling code.

How do you use CSS to create text effects, such as text shadows and gradients? How do you use CSS to create text effects, such as text shadows and gradients? Mar 14, 2025 am 11:10 AM

The article discusses using CSS for text effects like shadows and gradients, optimizing them for performance, and enhancing user experience. It also lists resources for beginners.(159 characters)

Creating Your Own Bragdoc With Eleventy Creating Your Own Bragdoc With Eleventy Mar 18, 2025 am 11:23 AM

No matter what stage you’re at as a developer, the tasks we complete—whether big or small—make a huge impact in our personal and professional growth.

Let's use (X, X, X, X) for talking about specificity Let's use (X, X, X, X) for talking about specificity Mar 24, 2025 am 10:37 AM

I was just chatting with Eric Meyer the other day and I remembered an Eric Meyer story from my formative years. I wrote a blog post about CSS specificity, and

See all articles