CSS相关知识

1. CSS是一种为结构化文档添加样式的计算机语言

 

使用场景1:一种样式重复使用。Do not Repeat Yourself.

使用场景2:简化网页设计

如:

 

 

 

 

It was the best of times, it was the worst of times,

it was the age of wisdom, it was the age of foolishness,

it was the epoch of belief, it was the epoch of incredulity

it was the season of Light, it was the season of Darkness,

it was the spring of hope, it was the winter of despair,

we had everything before us, we had nothing before us,

we were all going direct to Heaven, we were all going direct the other way

in short, the period was so far like the present period,

that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

-- Charles Dickens

 

 

做成一个外部链接

CSS为什么叫做层叠样式表,对样式的设定可以是多层的,而究竟采用哪一层采用就近原则。

 

2. CSS与DIV

内联样式

 


A robot may not injure a human being or, through inaction, allow a human being to come to harm.

 嵌入样式

 






A robot must obey orders given it by human beings except where such orders would conflict with the First Law.

 

 外联样式(推荐)

 



A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.

  h1.css

 

h1 {font-family:宋体;font-size:12pt;color:blue}
 

 

CSS语句格式

选择符{属性:值} 如: p {font-size:16}

 

html选择符

class选择符,如:

 





The Creation of Éa

Only in silence the word,
only in dark the light,
only in dying life:
bright the hawk's flight on the empty sky.

 

ID选择符,如:

 






To the time to life, rather than to life in time

 

 包含选择符,如:

 





The Childhood Of Humankind Ends

The Childhood Of Humankind Ends

 

 组合选择符,如:

 

 

 

DIV--层布局

传统的网页布局是用表格(table)来做的,整张网页其实就是一个大的嵌套的表格:简陋网页用表格来做布局还是相当方便的,不过当网页内容多起来,表格的嵌套会变的非常复杂。

 

另外一种常用方法是采用div,也就是层,来进行网页布局。

首先是页面作为最底层,放上一层背景,在背景上建立一个新层,放上logo,header,sidedar,foot,content几个块,在每个块上根据需要继续建立层。

这种方式非常自然,做起来也像搭积木一样流畅。

 

例子:

1 html

 



Yeats




When You Are Old

When you are old and grey and full of sleep,
And nodding by the fire, take down this book,
And slowly read, and dream of the soft look
Your eyes had once, and of their shadows deep;
How many loved your moments of glad grace,
And loved your beauty with love false or true,
But one man loved the pilgrim Soul in you,
And loved the sorrows of your changing face;
And bending down beside the glowing bars,
Murmur, a little sadly, how Love fled
And paced upon the mountains overhead
And hid his face amid a crowd of stars.

My Email

 

2 css

body {font-size:20px;margin:0px;text-align:center}

#container {width:100%}

#header {
width:800px;
margin:0 auto;
height:100px;
background-color:green;
}

#mainbody {
width:800px;
height:400px;
margin:0 auto;
}

#sidebar {
float:left;
width:200px;
height:400px;
background-color:orange;
}

#content {
float:right;
width:600px;
height:400px;
color:white;
background-color:black;
}

#foot {
margin:0 auto;
height:100px;
width:800px;
background-color:yellow;
}

3 div

 



        When you are old and grey and full of sleep,
        And nodding by the fire, take down this book,
        And slowly read, and dream of the soft look
        Your eyes had once, and of their shadows deep;
        How many loved your moments of glad grace,
        And loved your beauty with love false or true,
        But one man loved the pilgrim Soul in you,
        And loved the sorrows of your changing face;
        And bending down beside the glowing bars,
        Murmur, a little sadly, how Love fled
        And paced upon the mountains overhead
        And hid his face amid a crowd of stars.
      
 

ps:

http://www.w3school.com.cn/

http://www.csszengarden.com/tr/chinese/

 

 

你可能感兴趣的:(应用,CSS,Gmail,Spring,HTML)