CSS 分类 (Classification) 实例

CSS 实例

  • CSS 背景实例
  • CSS 文本实例
  • CSS 字体(font)实例
  • CSS 边框(border)实例
  • CSS 外边距 (margin) 实例
  • CSS 内边距 (padding) 实例
  • CSS 列表实例
  • CSS 表格实例
  • 轮廓(Outline)实例
  • CSS 尺寸 (Dimension) 实例
  • CSS 分类 (Classification) 实例
  • CSS 定位 (Positioning) 实例
  • CSS 伪类 (Pseudo-classes)实例
  • CSS 伪元素 (Pseudo-elements)实例

01如何把元素显示为内联元素和块级元素

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>01如何把元素显示为内联元素和块级元素</title>
<style type="text/css">
p.one {
display: inline;
} div {
display: none;
} span {
display: block;
}
</style>
</head> <body>
<p class="one">我这个段落被设置为内联元素。我这个段落被设置为内联元素。我这个段落被设置为内联元素。</p> <p class="one">哥俩好,我也是inline元素!哥俩好,我也是inline元素!哥俩好,我也是inline元素!</p> <div>我不是p而是div,所以内容不会显示出来!</div>
<p>我是一个段落随便写点啥我是一个段落随便写点啥<span>我这个span元素被设置为块级元素。。块级元素。。!!</span>我是一个段落随便写点啥我是一个段落随便写点啥一个段落随便写点啥我是一个段落随便写点啥我是一个段落随便写点啥我是一个段落随便写点啥<span>所以我们两个span元素就换行了。。换行了。。!!</span>我是一个段落随便写点啥我是一个段落随便写点啥我是一个段落随便写点啥</p>
</body> </html>


02浮动属性的简单应用

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>02浮动属性的简单应用</title>
<style type="text/css">
img {
float: right;
}
</style>
</head> <body>
<p>
<img src="2.jpg" /> This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This
is some text. This is some text. This is some text. This is some text. This is some text.
</p>
</body> </html>


03将带有边框和边界的图像浮动于段落的右侧

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>03将带有边框和边界的图像浮动于段落的右侧</title>
<style type="text/css">
img {
float: right;
border: 1px solid black;
margin: 0px 0px 15px 20px;
}
</style>
</head> <body>
<p>
<img src="2.jpg" /> This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This
is some text. This is some text. This is some text. This is some text. This is some text.
</p>
</body> </html>


04带标题的图像浮动于右侧

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>04带标题的图像浮动于右侧</title>
<style type="text/css">
div {
width: 300px;
float: right;
border: 1px solid black;
margin: 0px 0px 15px 20px;
padding: 10px;
text-align: center;
}
</style>
</head> <body>
<div>
<img src="2.jpg" />
<br /> CSS is fun!
</div>
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This
is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is
some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some
text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This
is some text. This is some text. This is some text.
</p>
</body> </html>


05使段落的首字母浮动于左侧

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>05使段落的首字母浮动于左侧</title>
<style type="text/css">
span {
float: left;
width: 0.7em;
font-size: 400%;
font-family: algerian, courier;
line-height: 80%;
}
</style>
</head> <body>
<p>
<span>T</span>his is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is
some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some
text. This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This
is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is
some text. This is some text. This is some text. This is some text.
</p>
<p>
在上面的段落中,文本的第一个字母包含在一个 span 元素中。这个 span 元素的宽度是当前字体尺寸的 0.7 倍。span 元素的字体尺寸是 400%,行高是 80%。span 中的字母字体是 "Algerian"
</p>
</body> </html>


06创建水平菜单

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>06创建水平菜单</title>
<style type="text/css">
ul {
float: left;
width: 100%;
padding: 0;
margin: 0;
list-style-type: none;
} a {
float: left;
width: 7em;
text-decoration: none;
color: white;
background-color: purple;
padding: 0.2em 0.6em;
border-right: 1px solid white;
} a:hover {
background-color: #ff3300
} li {
display: inline
}
</style>
</head> <body>
<ul>
<li><a href="#">链接1</a></li>
<li><a href="#">链接2</a></li>
<li><a href="#">链接3</a></li>
<li><a href="#">链接4</a></li>
</ul>
<p>
在上面的例子中,我们把 ul 元素和 a 元素浮向左浮动。li 元素显示为行内元素(元素前后没有换行)。这样就可以使列表排列成一行。ul 元素的宽度是 100%,列表中的每个超链接的宽度是 7em(当前字体尺寸的 7 倍)。我们添加了颜色和边框,以使其更漂亮。
</p>
</body> </html>


07创建无表格的首页

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>07创建无表格的首页</title>
<style type="text/css">
div.container {
width: 100%;
border: 3px solid yellow;
margin: 0;
line-height: 150%;
} div.header,
div.footer {
padding: 0.2em;
color: green;
background-color: purple;
clear: left;
} h1.header {
margin: 0;
padding: 0.2em;
} div.left {
float: left;
width: 160px;
padding: 1em;
margin: 0;
} div.content {
margin-left: 200px;
border-left: 1px solid black;
padding: 1em;
}
</style>
</head> <body>
<div class="container"> <div class="header">
<h1 class="header">浣溪沙·一曲新词酒一杯</h1>
</div> <div class="left">
<p>听一支新曲喝一杯美酒,还是去年的天气旧日的亭台,西落的夕阳何时再回来?</p>
</div> <div class="content">
<h2>浣溪沙·一曲新词酒一杯</h2>
<p>一曲新词酒一杯,去年天气旧亭台。夕阳西下几时回?</p>
<p>无可奈何花落去,似曾相识燕归来。小园香径独徘徊。</p>
</div> <div class="footer">此词虽含伤春惜时之意,却实为感慨抒怀之情。</div> </div> </body> </html>


08定位:相对定位

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>08定位:相对定位</title>
<style type="text/css">
h2.left {
position: relative;
left: -20px;
} h2.right {
position: relative;
left: 50px;
}
</style>
</head> <body>
<h2>我是位于正常位置的标题,相对定位会按照我的原始位置对我进行移动</h2>
<h2 class="left">样式 "left:-20px" 从我的左侧位置减去 20 像素</h2>
<h2 class="right">样式 "left:50px" 向我的左侧位置增加 50 像素</h2> </body> </html>


09定位:绝对定位

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>09定位:绝对定位</title>
<style type="text/css">
h2.abs {
position: absolute;
left: 100px;
top: 150px;
}
</style>
</head> <body>
<h2 class="abs">我是带有绝对定位的标题</h2>
<p>通过绝对定位,元素可以放置到页面上的任何位置。下面的标题距离页面左侧 100px,距离页面顶部 150px。</p>
</body> </html>


10定位:固定定位

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>10定位:固定定位</title>
<style type="text/css">
p.one {
position: fixed;
left: 10px;
top: 30px;
} p.two {
position: fixed;
right: 10px;
top: 30px;
}
</style>
</head> <body>
<p class="one">一些文本。</p>
<p class="two">更多的文本。</p>
</body> </html>


11如何使元素不可见

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>11如何使元素不可见</title>
<style type="text/css">
h1.visible {
visibility: visible;
} h1.invisible {
visibility: hidden;
}
</style>
</head> <body>
<h1 class="visible">这是可见的标题</h1>
<h1 class="invisible">这是不可见的标题</h1>
</body> </html>


12把表格元素设置为collapse

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>12把表格元素设置为 collapse</title>
<style type="text/css">
tr.no {
visibility: collapse;
}
</style>
</head> <body>
<table border="1">
<tr class="yes">
<td>中国

W3School-CSS 分类 (Classification) 实例的更多相关文章

  1. CSS 分类 (Classification) 实例

    CSS 分类 (Classification) 实例CSS 分类属性 (Classification)CSS 分类属性允许你控制如何显示元素,设置图像显示于另一元素中的何处,相对于其正常位置来定位元素 ...

  2. CSS 分类 (Classification)

    ★★CSS 分类属性 (Classification)★★ ⑴CSS 分类属性允许你控制如何显示元素,设置图像显示于另一元素中的何处,相对于其正常位置来定位元素,使用绝对值来定位元素,以及元素的可见度 ...

  3. 【转】精选30个优秀的CSS技术和实例

    今天,我为大家收集精选了30个使用纯CSS完成的强大实践的优秀CSS技术和实例,您将在这里发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等-这些实例都是使用纯CSS和HTML实现的. ...

  4. 精选30个优秀的CSS技术和实例

    精选30个优秀的CSS技术和实例   投递人 墙头草 发布于 2008-12-06 20:57 评论(97) 有17487人阅读 原文链接 [收藏] « » 今天,我为大家收集精选了30个使用纯CSS ...

  5. css技术和实例

    今天,我为大家收集精选了30个使用纯CSS完成的强大实践的优秀CSS技术和实例,您将在这里发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等-这些实例都是使用纯CSS和HTML实现的. ...

  6. 30个优秀的CSS技术和实例 By 彬Go 2008-12-04

    在这里可发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等…这些实例都是使用纯CSS和HTML实现的.单击每个实例的标题可以被转向到该技术实例的相关教程或说明页面(英文),单击每个实例 ...

  7. CSS 尺寸 (Dimension) 实例

    CSS 尺寸 (Dimension) 实例CSS 尺寸属性CSS 尺寸属性允许你控制元素的高度和宽度.同样,还允许你增加行间距. 属性 描述height 设置元素的高度.line-height 设置行 ...

  8. CSS 边框(border)实例

    CSS 边框(border)实例:元素的边框 (border) 是围绕元素内容和内边距的一条或多条线. CSS border 属性允许你规定元素边框的样式.宽度和颜色. CSS 边框属性属性 描述bo ...

  9. CSS 字体(font)实例

    CSS 字体(font)实例CSS 字体属性定义文本的字体系列.大小.加粗.风格(如斜体)和变形(如小型大写字母).CSS 字体系列在 CSS 中,有两种不同类型的字体系列名称: 通用字体系列 - 拥 ...

随机推荐

  1. 【JUC】JDK1.8源码分析之CyclicBarrier(四)

    一.前言 有了前面分析的基础,现在,接着分析CyclicBarrier源码,CyclicBarrier类在进行多线程编程时使用很多,比如,你希望创建一组任务,它们并行执行工作,然后在进行下一个步骤之前 ...

  2. 【字符编码】Java字符编码详细解答及问题探讨

    一.前言 继上一篇写完字节编码内容后,现在分析在Java中各字符编码的问题,并且由这个问题,也引出了一个更有意思的问题,笔者也还没有找到这个问题的答案.也希望各位园友指点指点. 二.Java字符编码 ...

  3. html5 canvas 画图表

    (function () { var canvas = document.createElement("canvas"); canvas.width = 800; canvas.h ...

  4. SpringData —— HelloWorld

    SpringData 简介 优点 简化数据库访问,减少数据访问层的开发量. 支持的数据库类型 支持 NoSQL 存储,如 MongoDB,Redis. 支持关系型数据存储技术,如 jdbc,jpa. ...

  5. 使用CodeDom动态生成类型

    .NET 3.5的时候加入了匿名类型这个特性,我们可以直接使用 new {name="abc"} 来直接生成一个对象.这个特性现在应用的地方很多,比如dapper的查询参数都是用匿 ...

  6. [C#] 获取打印机列表

    一:获得本地安装的打印机列表 注:(如果在"设备和打印机"中已经添加了局域网的打印机设备,也算是本地安装的打印机:没有添加的则算作局域网打印机) 1,通过 C# 中 Printer ...

  7. 如何在windows下的Python开发工具IDLE里安装其他模块?

    以安装Httplib2模块为例 1 下载模块 到 “https://code.google.com/p/httplib2/” 下载一款适合你的压缩包“httplib2-0.4.0.zip” 2 解压下 ...

  8. 从零开始学Python第六周:面向对象基础(需修改)

    标签(空格分隔): 面向对象 一,面向对象基础 (1)面向对象概述 面向过程:根据业务逻辑从上到下写代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类 ...

  9. Java集合概述

    容器,是用来装东西的,在Java里,东西就是对象,而装对象并不是把真正的对象放进去,而是指保存对象的引用.要注意对象的引用和对象的关系,下面的例子说明了对象和对象引用的关系. String str = ...

  10. 如何用ORM支持SQL语句的CASE WHEN?

    OQL如何支持CASE WHEN? 今天,一个朋友问我,OQL可否支持CASE WHEN语句?他给的示例SQL如下: then '启用' else '停用' from tb_User OQL是SOD框 ...