search
HomeWeb Front-endHTML TutorialSome suggestions for DIV CSS layout_html/css_WEB-ITnose

http://www.cnblogs.com/bindsang/archive/2008/07/28/1254385.html

Some suggestions for DIV CSS layout

I have been playing with Web refactoring for a while, and I have gained some experience. Netizens often ask Caizi some questions about layout. Some friends in the SvnHost group asked Caizi to write more tutorials about layout to help some novices. Caizi also promised to write more about Caizi’s own experience and experience in layout. Share your experience with everyone.

Many people think that web reconstruction is just a simple DIV CSS layout. This is obviously a wrong concept. I don’t want to explain it more in detail. There are a lot of articles on this aspect. DIV CSS layout is indeed a very important part of reconstruction. Today, Caizi will talk about some suggestions on layout.

1. Please design a layout that suits your own style (including XHTML and CSS).

In fact, every website designer generally has his own style, so please design a set of layout methods that you like individually, including XHTML and CSS. Please be sure to skillfully remember the dependency relationships between various layout modules. A schematic diagram will be attached at the end of this article.

2. Please be sure to add a unique ID identifier to each module participating in the layout. Such as #header, #content, #footer, etc.

Maybe you don’t need to define separate styles for each module in CSS at the moment, but do you dare to say that you won’t need it in the future? If you are not sure, please add ID. And please understand that the ID mark is not only for the convenience of defining its style in CSS, it is also a DOM node. For future expansion, this ID is also very necessary.

3. Please do not use any other element tags except div to participate in the layout.

Many people may have questions about this. Don’t we even need to use tags like span, ul, li, p, h1, h2...? Of course not, please see clearly, Caizi refers to the layout, and these tags are just containers for some content that need to be used to render some effects, and have nothing to do with the layout.

4. Some places in the content require special rendering. You can use element tag styles for rendering. Please don't complicate it and use other class selectors for rendering.

This point is a bit hard to explain, so please read this article: Clever use of uncommon tag elements in XHTML, that’s about it.

5. Please make good use of comments, indentation, and blank lines.

No matter what code it is, whether it is XHTML, CSS, JS, or background program code, it all applies. For example, in the XHTML code, a comment is added at the beginning of each module to explain what module it is. Please pay attention to the indentation of the nested divs at each level. The next level has one more indentation than the previous level. The structure must be clearly visible at a glance. Please don't be stingy with one or two blank lines between each module. If you do these things, you will find that whether you look at the source code yourself or others look at the source code, it will be easy to get started. If you need to modify it, , will greatly improve efficiency.

6. When working on a project, be sure to write a development document.

Development documents are some key points in the development process, which must be recorded, such as the directory structure (if necessary, it is best to record the functions of each directory and file), page layout, etc., so that you can conveniently record them at any time After reading it, if someone needs to change people to do this project in the future, it will be easy for them to take over.

That’s all for now, there may be many more things worth noting, I will add them as soon as I think of it, thank you!


Regarding point 1, here is a layout diagram of a corporate website that Caizi helped people make some time ago:

This is a typical layout of three rows and two columns, above It is the header, the middle is content, the middle is divided into left and right parts (sidebar and main), and the bottom is footer. The big structure is very clear and no further explanation is needed. Let’s take a rough look at how the specific layout is:
The outermost layer of the website is a large container #wrap, and all the content is packed inside. As long as its width is defined, the whole situation will take effect. It is recommended to define an outer container in this way. layer container.
The top is the header container, which has three modules, divided into upper and lower layers. The upper layer is divided into two left and right modules, logo and banner, and the lower layer is the nav module, which is the menu.
In the middle is the content container, which is divided into two large modules on the left and right, sidebar and main. The sidebar has two upper and lower modules, login and recommend modules, and the main on the right also has two upper and lower modules, ad and product.
The bottom is the footer container.
Finally, a simple source code of the above layout is attached for reference only!
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 标准的三行两列布局 
  
    
Logo
    
Banner
    
nav | nav | nav | nav | nav | nav | nav | nav | nav | nav | nav | nav | nav
  
  
    
      
Login
      
Recommend
    
    
      
AD
      
Product
    
  
  
footer


The work of the romantic talent, please keep the original address link when reposting, thank you for your cooperation!
Caizi’s Nest: http://www.54caizi.org/

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
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

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

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)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor