Home >Web Front-end >HTML Tutorial >Some suggestions for DIV CSS layout_html/css_WEB-ITnose

Some suggestions for DIV CSS layout_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 12:31:26973browse

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!
 标准的三行两列布局 

     
         
             
Product
    
  
  


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