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. spring笔记--依赖注入之针对不同类型变量的几种注入方式

    控制反转和依赖注入讲的都是一个概念,只不过是站在了不同的角度,所谓的依赖注入: 是指在运行期,由外部容器动态地将依赖对象注入到组件中.当spring容器启动后,spring容器初始化,创建并管理bea ...

  2. 浅析.NET的反射特性

    在.net框架体系内,反射特性较多的应用到.反射的相关定义分为两种. 自然解释:射是一种自然现象,表现为受刺激物对刺激物的逆反应:这是反射的字面解释,我们看一下计算机编程中的反射: 编程解释:通过 S ...

  3. (转载)构建public APIs与CORS

    from: https://segmentfault.com/a/1190000000709909 理由:在操作层面详细的讲解了跨域的操作.尤其是对于option请求的详解.收藏. 在构建Public ...

  4. HTML基本元素(一)

    HTML基本元素(一) 1.换行符 <br /> Ps:br 是换行(Break)的缩写,文本会在这个标签的地方换行. 实例: 第一行<br />第二行 2.段落 <p& ...

  5. SQL Server 存储(1/8):理解数据页结构

    我们都很清楚SQL Server用8KB 的页来存储数据,并且在SQL Server里磁盘 I/O 操作在页级执行.也就是说,SQL Server 读取或写入所有数据页.页有不同的类型,像数据页,GA ...

  6. Autofac - 事件

    Autofac在提供之前那些方法的时候, 同时提供了五个事件, 这一篇就看一下这几个事件. 一.五大事件 builder.RegisterType<Person>().As<IPer ...

  7. .NET正则表达式基础入门(一)

    字符组 正则表达式的字符组十分简单,就是列出你所想要匹配的字符.阅读本章前,建议先下载我于CSDN上传的示例代码,下载无需分数,下载链接. 1.普通字符组 普通字符组,列出所有你需要匹配的字符. 例如 ...

  8. NoSQL

    Not Only Sql,弱一致性模型,非关系型.分布式.支持水平扩展的数据库设计模式,区别于传统关系型数据库严格的事务一致性和范式约束.分布式缓存是NoSQL一种实现形式. 参考:

  9. sqlserver 多库查询 sp_addlinkedserver使用方法(添加链接服务器)

    sqlserver 多库查询 sp_addlinkedserver使用方法(添加链接服务器) 我们日常使用SQL Server数据库时,经常遇到需要在实例Instance01中跨实例访问Instanc ...

  10. 【NopCommerce源码架构学习-一】--初识高性能的开源商城系统cms

    很多人都说通过阅读.学习大神们高质量的代码是提高自己技术能力最快的方式之一.我觉得通过阅读NopCommerce的源码,可以从中学习很多企业系统.软件开发的规范和一些新的技术.技巧,可以快速地提高我们 ...