Home >Web Front-end >HTML Tutorial >Div css study notes_html/css_WEB-ITnose
一些比较常用属性
font 字体
color 颜色
font-size 字体大小
text-align 文本位置
background 背景
margin 外补丁
padding 内补丁
border 边框
float 布局
下边是实例
CSS布局常用的方法:float:none|left|right
取值:
none:?默认值。对象不飘浮
left:?文本流向对象的右边
right:?文本流向对象的左边
它是怎样工作的,看个一行两列的例子
xhtml代码:
CSS代码:
#wrap{width:100;height:auto;}
#column1{float:left;width:40;}
#column2{float:right;width:60;}
.clear{clear:both;}
position:static|absolute|fixed|relative
取值:
static:?默认值。无特殊定位,对象遵循HTML定位规则
absolute:?将对象从文档流中拖出,使用left,right,top,bottom等属性相对于其最接近的一个最有定位设置的父对象进行绝对定位。如果不存在这样的父对象,则依据body对象。而其层叠通过z-index属性定义
fixed:?未支持。对象定位遵从绝对(absolute)方式。但是要遵守一些规范
relative:?对象不可层叠,但将依据left,right,top,bottom等属性在正常文档流中偏移位置
它来实现一行两列的例子
xhtml代码:
CSS代码:
#wrap{position:relative;/*相对定位*/width:770px;}
#column1{position:absolute;top:0;left:0;width:300px;}
#column2{position:absolute;top:0;right:0;width:470px;}
他们的区别在哪?
显然,float是相对定位的,会随着浏览器的大小和分辨率的变化而改变,而position就不行了,所以一般情况下还是float布局!
CSS常用布局实例
单行一列
body{margin:0px;padding:0px;text-align:center;}
#content{margin-left:auto;margin-right:auto;width:400px;}
两行一列
body{margin:0px;padding:0px;text-align:center;}
#content-top{margin-left:auto;margin-right:auto;width:400px;}
#content-end{margin-left:auto;margin-right:auto;width:400px;}
三行一列
body{margin:0px;padding:0px;text-align:center;}
#content-top{margin-left:auto;margin-right:auto;width:400px;width:370px;}
#content-mid{margin-left:auto;margin-right:auto;width:400px;}
#content-end{margin-left:auto;margin-right:auto;width:400px;}
单行两列
#bodycenter{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}
#bodycenter#dv1{float:left;width:280px;}
#bodycenter#dv2{float:right;width:420px;}
两行两列
#header{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}
#bodycenter{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}
#bodycenter#dv1{float:left;width:280px;}
#bodycenter#dv2{float:right;width:420px;}
三行两列
#header{width:700px;margin-right:auto;margin-left:auto;}
#bodycenter{width:700px;margin-right:auto;margin-left:auto;}
#bodycenter#dv1{float:left;width:280px;}
#bodycenter#dv2{float:right;width:420px;}
#footer{width:700px;margin-right:auto;margin-left:auto;overflow:auto;clear:both;}
单行三列
绝对定位
#left{position:absolute;top:0px;left:0px;width:120px;}
#middle{margin:0px190px0px190px;}
#right{position:absolute;top:0px;right:0px;width:120px;}
float定位
xhtml代码:
CSS代码:
#wrap{width:100;height:auto;}
#column{float:left;width:60;}
#column1{float:left;width:30;}
#column2{float:right;width:30;}
#column3{float:right;width:40;}
.clear{clear:both;}
float定位二
xhtml代码:
CSS代码:
body{
margin:0;
padding-left:200px;/*LCfullwidth*/
padding-right:190px;/*RCfullwidth CCpadding*/
min-width:200px;/*LCfullwidth CCpadding*/
}
.column{
position:relative;
float:left;
}
#center{
width:100;
}
#left{
width:200px;/*LCwidth*/
right:200px;/*LCfullwidth*/
margin-left:-100;
}
#right{
width:190px;/*RCwidth*/
margin-right:-100;
}
写一些比较简单的,这些应该多去实践才会真正的掌握
我写的这个
xhtml代码:
CSS code:
body {background-color:#FFFFFF;margin: 0px;text-align:center;line-height:150%;font-size:12px;color:#AA0000; font-family:"宋体"}
#enter{;font-size:20px;font-family:Impact;margin-top:100px;}
#enter a{font-size:36px;color:# AA0000; text-decoration:none}
#enter a:hover{color:#FFFFFF; background:#AA0000; padding:2px;}
#ziuotext{margin-top:30px;}
#copyright {margin-top:50px;}
a{color:#AA0000; text-decoration:none}
a:hover{color:#FFFFFF; background:#AA0000; padding:2px;}
The main ones used are padding and margin
Some commonly used css names
Header: header
Login bar: loginbar
Logo: logo
sidebar: sidebar
advertising: banner
navigation: nav
sub-navigation: subnav
menu: menu
sub-menu: submenu
search: search
scroll: scroll
Page body: main
Content: content
Tab: tab
Article list: list
Prompt message: msg
Tips: tips
Column title: title
Join :joinus
guide: guild
service: service
hot spot: hot
news: news
download: download
registration: regsiter
status: status
button: btn
Vote: vote
Partner: partner
Friendly link: friendlink
Footer: footer
Copyright: copyright
Naming of CSS ID
Coat: wrap
Main navigation: mainnav
Sub-navigation: subnav
Footer: footer
Whole page: content
Header: header
Footer: footer
Trademark: label
title: title
main navigation: mainbav (globalnav)
top navigation: topnav
side navigation: sidebar
left navigation: leftsidebar
right navigation: rightsidebar
Flag: logo
slogan: banner
Menu content 1: menu1content
Menu capacity: menucontainer
Submenu: submenu
Side navigation icon: sidebarIcon
Note: note
Bread Crumb: Breadcrumb (i.e. navigation prompt for the location of the page)
Container: container
Content: content
Search: search
Login: Login
Ribbon: shop (such as shopping cart, checkout counter) )
Current current
Comments available when editing style sheets can be written like this
<-- Footer -->
Content area
<-- End Footer -->
Style file naming
Main master.css
Layout, layout.css
Columns columns.css
Text font.css
Print style print.css
Themes.css
Commonly used Chinese and English comparison table for websites
Site Map
Company Profile Profile or Company Profile or Company
Equipment Equipment
Company Honors Glories Glories
Corporate Culture Culture Culture
Product DisplayProduct Product
Qualifications CertificationQuality Certification
Scale Scale
Sales Network
organization organization
Join In Cooperation
Technology Technology
Manager`s oration
Development History
Engineering Projects
Business Scope
Branches
Supply & Demand
Business Philosophy Operation Principle
Sales Sales
Contact Us Contact Us
Information Information
Return to the homepageHomepage Homepage
Product order order
Browse By Category
E-business
Company StrengthStrength Strength
Copy Right
Hot Link
Application Fields
Human Resource Hr
Leader`s oration
Enterprise Qualification Enterprise Qualification
Industry News Trade News
Industry Trends Trends
Customer Message
Customer Service Customer Service
News & Trends
Company Name
Sales Hot-Line
Contact Contact Person
Your Requirements
In Construction
Certificate Certificate
Address ADD Add
Postal Code Zipcode
Telephone TEL Tel
Fax Fax
Product Name
Description Description
Price
Brand
Specification
Size
Manufacturer Manufacturer Manufacturer
Model
Product number Item No.
Technique Data
Product Description Description
Production Place
Sales Information
Application
Forum
On-line order
Enterprise-establishing
Bid Inviting
General
Achievements
Join Us
Join Us
Great Event
Dynamic Trends
Service Service
Investment
Industry
Planning Programming
Environment
Send Delivery
Submit
Rewrite Reset
Login Enter
Register Login
Community
Business Introduction
Online Inquiry Inquiry
Download Center Download
Member Entrance
Feedback
FAQ
General Profile
Education & Training
Amusement Park
Online Communication
Special Report
This article comes from cssrain.cn Original link: http:// www.cssrain.cn/article.asp?id=707