Home  >  Article  >  Web Front-end  >  What are the techniques for CSS layout?

What are the techniques for CSS layout?

php中世界最好的语言
php中世界最好的语言Original
2017-11-23 14:07:171936browse

How does CSS need to be laid out? What aspects should be paid attention to when designing CSS layout? What are the techniques for CSS layout? Today we will summarize them one by one for you. How to have good CSS layout.

Everyone knows that when the PS (pictures) taken from graphic designers are refactored by CSS reconstructors, the web page art pictures need to be analyzed. Only through good analysis can CSS layout be achieved.

Therefore, DIV CSS layout accounts for a large part of the analysis. When we analyze web page art pictures, we do not analyze whether the pictures are good-looking, but analyze the art pictures of the web page based on the css layout, and CSS layout analysis directly affects future css. A step to reconstruct whether the html page is easy to write.

Layout knowledge:

DIV+CSS layout, CSS layout is the collective name for web pages (html) developed and produced through div tags + css style sheet code.

Benefits of div+css layout: easy to maintain, beneficial to SEO (Google uses webpage opening speed as a ranking factor and SEO factor), webpage opening speed is faster, and it complies with web standards, etc.

Think about the layout before making a div+css webpage:

First we get a webpage art picture and we will layout it from top to bottom, top to middle and bottom, left and right, top to middle (including left and right) framework to think about.

The following is a example to explain the CSS layout analysis. We use the list page to analyze the CSS layout:

First we can analyze our DIV CSS layout and reconstruct the structure of this page. We can see that the frame has upper, middle and lower structures, including left and right structures.

Therefore, when we write the CSS and HTML of this page, we should first write the CSS and HTML from top to bottom and from the outside to the inside.

We first create a web folder and create a new html page in this folder named index.html and a css file named index.css. The trick here is to import the template to build the CSS and HTML initial page, and then reference the CSS file to the HTML, which is the CSS template I introduced in the template, and then write and add CSS based on the CSS template.

The following is the html code of index.html:

The following is the quoted content:

<!DOCTYPE "> 
<html "> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>css布局案例实验页面</title> 
<link href="index.css" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
<div id="header">我是头部(上)</div> 
<div id="centers"> 
<div class="c_left">我是中的左</div> 
<div class="c_right">我是中的右</div> 
<div class="clear"> </div> 
</div> 
<div id="footer">我是底部(下)</div> 
</body> 
</html>

The CSS code of index .css is as follows:

The following is Quoted content:

body, div, address, blockquote, iframe, ul, ol, dl, dt, dd, li, dl, h1, h2, h3, h4, h5, h6, p, pre, table, caption, th, td, form, legend, fieldset, input, button, select, textarea {margin:0; padding:0; font-weight: normal;font-style: normal;font-size: 100%; font-family: inherit;} 
ol, ul ,li{list-style: none;} 
img {border: 0;} 
body {color:#000;background:#FFF; text-align: center; font: 12px/1.5 Arial, Helvetica, sans-serif;} 
.clearfix:after {clear:both; content:"."; display:block; height:0pt; visibility:hidden; overflow:hidden;} 
.clear{clear:both;height:1px; margin-top:-1px; width:100%;} 
.dis{display:block;} 
.undis{display:none;} 
/*此上面代码是初始CSS模板,下面是新写CSS布局框架代码*/ 
#header ,#centers ,#footer{ width:100%; margin:0 auto; clear:both;font-size:18px; line-height:68px; font-weight:bold;} 
#header{ height:68px; border:1px solid #CCCCCC; } 
#centers{ padding:8px 0;} 
#footer{ border-top:1px solid #CCCCCC; background:#F2F2F2;} 
#centers .c_left{ float:left; width:230px; border:1px solid #00CC66; background:#F7F7F7; margin-right:5px; } 
#centers .c_right{ float:left; width:500px;border:1px solid #00CC66; background:#F7F7F7}

You can try out these two pieces of code and create a new one. We will lay out the CSS and html framework of the above art page, and then continue to add CSS and html source code according to each content.

I believe everyone already understands the importance and explanation of css layout. For more exciting content, please pay attention to other related articles on the php Chinese website!

Related reading:

HTML table style

How to use min-height and max-height in CSS

How to display circular images in css3

The above is the detailed content of What are the techniques for CSS layout?. For more information, please follow other related articles on the PHP Chinese website!

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