`
zhou.xingbo
  • 浏览: 53049 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

CSS相关知识

阅读更多

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

 

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

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

如:

 

<style type="text/css">
p {
text-align:center;
}
p.red {
color:red;
font-size:24px
}
p.purple {
color:purple;
font-size:18px
}
p.blue {
color:blue;
font-size:12px
}
p.left {
text-align:left;
}
</style>
 

 

 

<p class="red">It was the best of times, it was the worst of times,</p>

<p class="purple">it was the age of wisdom, it was the age of foolishness,</p>
<p class="blue">it was the epoch of belief, it was the epoch of incredulity</p>
<p class="blue">it was the season of Light, it was the season of Darkness,</p>
<p class="purple">it was the spring of hope, it was the winter of despair,</p> 
<p class="red">we had everything before us, we had nothing before us,</p>

<p class="red">we were all going direct to Heaven, we were all going direct the other way</p>
<p class="purple">in short, the period was so far like the present period,</p>
<p class="blue">that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. </p>
<p class="left">-- Charles Dickens</p>

 

 

做成一个外部链接

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

 

2. CSS与DIV

内联样式

 

<body>
<h1 style="font-size:12pt;color:blue">A robot may not injure a human being or, through inaction, allow a human being to come to harm.
</h1>
</body>

 嵌入样式

 

<head>
<style type="text/css">
h1 {font-family:宋体;font-size:12pt;color:blue}
</style>

</head>
<body>
<h1>A robot must obey orders given it by human beings except where such orders would conflict with the First Law.</h1>
</body>

 

 外联样式(推荐)

 

<link rel="stylesheet" href="h1.css" type="text/css">
</head>
<body><h1>A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. <head></h1></body>

  h1.css

 

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

 

CSS语句格式

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

 

html选择符

class选择符,如:

 

<head>
<style type="text/css">
.center {text-align:center;color:blue}
</style>
</head>
<body>
<h1 class="center">The Creation of Éa</h1>

<pre class="center">
Only in silence the word,
only in dark the light,
only in dying life:
bright the hawk's flight on the empty sky.
</pre>
</body

 

ID选择符,如:

 

<head>

<style type="text/css">
#title{text-align:center;color:blue}
</style>
</head>
<body>
<p id="title">To the time to life, rather than to life in time </p>
</body>

 

 包含选择符,如:

 

<head>
<style type="text/css">b
table  p{font-size:20;color:red}
</style>
</head>
<body>
<table>
<tr><td><p>The Childhood Of Humankind Ends</p></td></tr>

</table>
<p>The Childhood Of Humankind Ends</p>
</body>

 

 组合选择符,如:

 

<style type="text/css">
h1,h2,h3{color:red}
</style>
 

 

DIV--层布局

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

 

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

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

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

 

例子:

1 html

 

<html>
<head>
<title>Yeats</title>

<style type="text/css" media="screen">

</style>
</head>
<body>
<h1>When You Are Old</h1>
<pre>
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.
</pre>

<hr>
<a href="mailto:renw1990@gmail.com">My Email</a>
</body>
</html>

 

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

 

<div id="container">
  <div id="header">
    <h1>When You Are Old</h1>      
  </div>
  <div id="mainbody">

    <div id="sidebar">
      <p><br><br>index</p>
      <p>download</p>
      <p>William Yeats</p>

      <p>Contact Me</p>
    </div>
    <div id="content">
      <pre>


        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.
      </pre>

    </div>
  </div>
  <div id="foot">
    <hr>      
    <a href="mailto:renw1990@gmail.com">My Email</a>
  </div>

</div>
 

ps:

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

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

 

 

分享到:
评论

相关推荐

    学习HTML与CSS相关知识.zip

    学习HTML与CSS相关知识学习HTML与CSS相关知识学习HTML与CSS相关知识 学习HTML与CSS相关知识学习HTML与CSS相关知识学习HTML与CSS相关知识 学习HTML与CSS相关知识学习HTML与CSS相关知识学习HTML与CSS相关知识 学习HTML...

    html和css相关知识思维导图

    里面将知识点分了一下类。 详情

    css的基本知识

    这里面讲述了css的一些基本知识点和一些常见的问题,在一学习过程中可能会用到

    HTML/CSS壁纸.zip

    这个"HTML/CSS壁纸.zip"压缩包显然包含了作者个人整理的HTML和CSS相关知识点,以壁纸的形式呈现,旨在帮助学习者随时复习和熟悉这些基础知识。 首先,HTML是网页的基础框架,它通过各种标签来定义内容的结构,如`...

    htmlcss多选题及答案,前端面试题含答案——HTML、CSS相关.docx

    HTML/CSS 相关知识点 在本节中,我们将详细介绍 HTML 和 CSS 相关的知识点,以便帮助读者更好地理解和掌握这些技术。 1. HTML 文档类型定义(DOCTYPE) HTML 文档类型定义(DOCTYPE)是 HTML 文档的开头部分,...

    css手册chm版

    7. **CHM格式优势**:CHM文件是一种压缩的HTML帮助文档,具有快速搜索功能,可以离线查看,节省存储空间,尤其适合开发环境,便于快速查找和学习CSS相关知识。 通过《CSS手册chm版》,开发者不仅可以深入理解CSS的...

    DIV+CSS教程——第一天XHTML_CSS基础知识

    DIV+CSS教程——第一天XHTML_CSS基础知识

    CSS理论知识 快速掌握css

    **CSS理论知识快速掌握** CSS,全称Cascading Style Sheets(层叠样式表),是网页设计中的核心技术之一,用于定义HTML或XML(包括如SVG、MathML等各种XML方言)文档的呈现。通过CSS,我们可以控制网页元素的布局、...

    css参考手册_v4.2.7_作者:飘零物语

    手册的CHM文件格式是Microsoft的 Compiled HTML Help,它将所有内容打包成一个可搜索的文档,方便用户快速查找和学习CSS相关知识点。《CSS参考手册_v4.2.7》作为全面的参考资料,不仅覆盖了以上的基本概念,还可能...

    关于CSS的3本有用的书

    以下是对标题和描述中提到的CSS相关知识点的详细解释: 1. **CSS基础知识**:CSS是一种层叠样式表语言,用于描述HTML或XML(包括SVG、XHTML等)文档的呈现。它的核心功能是将内容与表现分离,使开发者可以独立地...

    css离线参考手册

    《CSS离线参考手册》是Web开发者不可或缺的工具之一,它详尽地涵盖了CSS(层叠样式表)的各个方面,帮助开发者在没有网络连接的情况下也能迅速查找和理解CSS相关知识。CSS是网页设计的核心技术之一,用于控制网页...

    CSS基础知识超全整理

    整理好的一份关于css的知识大纲,希望能够帮助到大家,可以用来复习回顾

    HTMLCSS.rar_HTMLCSS_css chm

    是一个包含HTML和CSS相关知识的压缩文件,其中主要资源是名为"HTMLCSS.CHM"的.chm(Microsoft帮助文件)文档,这通常是一个包含详细教程或指南的电子书格式。另一个文件"www.pudn.com.txt"可能是来源或版权信息的...

    CSS Pocket Reference英文第4版(带阅读笔记与部分翻译)

    标签通常用于快速分类和定位信息,此标签表明这本书专门讨论CSS,对于想要快速查找CSS相关知识的读者来说是非常有用的。 从部分内容中,我们可以了解到书中讨论了多个CSS的方面: 1. **基础概念**:涉及到向HTML和...

    csscss知识点总结

    讲解一些刚入门的有关css的知识点,有助于我们能更容易的学懂css语言,例如表单制作,框架等等。

    CSS權威指南.pdf

    从上述信息中,我们可以推测该电子书可能覆盖的CSS相关知识点,虽然具体内容无从得知,但通常CSS权威指南类的书籍会覆盖以下几个核心方面: 1. CSS基础:介绍CSS的作用、历史和它如何与HTML结合使用。 2. 选择器:...

    CSS_HELP_3.0.rar_Help!_在css中help

    这个手册可能会涵盖以下CSS知识点: 1. **CSS基础**:选择器的使用,如类选择器、ID选择器、元素选择器,以及更高级的选择器如伪类和伪元素。 2. **属性与值**:包括颜色、字体、边距、填充、布局等数百个CSS属性...

    CSS Mastery 3rd edition

    《CSS Mastery 3rd edition》一书是由Andy Budd和Emil Björklund所著,这是关于CSS...以上内容覆盖了《CSS Mastery 3rd edition》这本书的概要知识点,为读者提供了一个关于书内可能包含的CSS相关知识点的全面概述。

    html,css,jsp相关知识总结

    html,css,jsp相关知识总结,便于进行html,css,jsp的学习

Global site tag (gtag.js) - Google Analytics