W3School-CSS 分类 (Classification) 实例
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) 实例的更多相关文章
- CSS 分类 (Classification) 实例
CSS 分类 (Classification) 实例CSS 分类属性 (Classification)CSS 分类属性允许你控制如何显示元素,设置图像显示于另一元素中的何处,相对于其正常位置来定位元素 ...
- CSS 分类 (Classification)
★★CSS 分类属性 (Classification)★★ ⑴CSS 分类属性允许你控制如何显示元素,设置图像显示于另一元素中的何处,相对于其正常位置来定位元素,使用绝对值来定位元素,以及元素的可见度 ...
- 【转】精选30个优秀的CSS技术和实例
今天,我为大家收集精选了30个使用纯CSS完成的强大实践的优秀CSS技术和实例,您将在这里发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等-这些实例都是使用纯CSS和HTML实现的. ...
- 精选30个优秀的CSS技术和实例
精选30个优秀的CSS技术和实例 投递人 墙头草 发布于 2008-12-06 20:57 评论(97) 有17487人阅读 原文链接 [收藏] « » 今天,我为大家收集精选了30个使用纯CSS ...
- css技术和实例
今天,我为大家收集精选了30个使用纯CSS完成的强大实践的优秀CSS技术和实例,您将在这里发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等-这些实例都是使用纯CSS和HTML实现的. ...
- 30个优秀的CSS技术和实例 By 彬Go 2008-12-04
在这里可发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等…这些实例都是使用纯CSS和HTML实现的.单击每个实例的标题可以被转向到该技术实例的相关教程或说明页面(英文),单击每个实例 ...
- CSS 尺寸 (Dimension) 实例
CSS 尺寸 (Dimension) 实例CSS 尺寸属性CSS 尺寸属性允许你控制元素的高度和宽度.同样,还允许你增加行间距. 属性 描述height 设置元素的高度.line-height 设置行 ...
- CSS 边框(border)实例
CSS 边框(border)实例:元素的边框 (border) 是围绕元素内容和内边距的一条或多条线. CSS border 属性允许你规定元素边框的样式.宽度和颜色. CSS 边框属性属性 描述bo ...
- CSS 字体(font)实例
CSS 字体(font)实例CSS 字体属性定义文本的字体系列.大小.加粗.风格(如斜体)和变形(如小型大写字母).CSS 字体系列在 CSS 中,有两种不同类型的字体系列名称: 通用字体系列 - 拥 ...
随机推荐
- C# 中实现单例模式
文章目录 简介 不安全线程的单例模式 简单安全线程带锁 双重检查 - 带锁 安全初始化 安全并且懒汉式静态初始化 带泛型的懒汉式单例 异常 提高效率 总结 简介 单例模式是软件工程中广为人知的设计模式 ...
- T-SQL高级查询语句
高级查询 1.连接查询,对结果集列的扩展select * from info select * from info,nation #形成笛卡尔积select * from info,nation wh ...
- Android 源码下载方法(Git 方式clone)
Android源码对于Android开发者来说,迟早有一天你会用到的,所以就记录一下,分享给读者,希望对读者有用 这里需要使用到Git相关知识,不清楚的可以先阅读,了解的可以跳过 Git-Tortoi ...
- 在Pycharm中使用GitHub
Pycharm是当前进行python开发,尤其是Django开发最好的IDE.GitHub是程序员的圣地,几乎人人都在用. 本文假设你对pycharm和github都有一定的了解,并且希望在pycha ...
- 基于STM32Cube的DAC数模转化
1. STM32Cube配置 1.1 DAC配置 1.2 TIM6 配置 1.3 利用Cube产生工程程序,MDK打开软件 在主循环上添加语句: HAL_TIM_Base_S ...
- Microsoft Visual Studio 2008 未能正确加载包“Visual Web Developer HTML Source Editor Package” | “Visual Studio HTM Editor Package”
在安装Microsoft Visual Studio 2008 后,如果Visual Studio 2008的语言版本与系统不一致时,比如:在Windows 7 English System 安装Vi ...
- 常用的WebForm 控件
首先回忆一下Html页中的12个表单元素 .文本类 文本框 <input type="text" id="" name="" valu ...
- WPF数据验证
当填写表单时,需要对填写的内容进行验证,检查数据是否符合要求,比如字符串的长度.日期的格式.数字等.WPF支持自定义验证规则,并提供可视化反馈,以便在输入无效值时向用户发出通知. 下面的示例将演示一个 ...
- 初识Java
Java是一种简单的.面向对象的.分布式的.解释的.安全的.可移植的.性能优异的多线程语言.它以极强的安全性.平台无关性.硬件结构无关性.语言简洁.面向对象的特点,在网络编程语言中占据了无可比拟的优势 ...
- P2P核心业务体系
看似一个简单的充值.提现按钮,背后可是巨多的逻辑和业务处理.