9月11日上午HTML有序列表、无序列表、网页的格式和布局
样式表
六、列表方块
1.有序列表变无序列表
<ol>
<li>张店</li> <li>桓台</li> <li>淄川</li>
</ol>
网页上显示为1. 张店 2. 桓台 3. 淄川 (竖向显示)
<ol style="list-style:none">
<li>张店</li>
<li>桓台</li>
<li>淄川</li>
</ol>
网页上显示 张店 桓台 淄川
list-style:none将列表前面的序号去掉,成为了无序列表。
<ol style="list-style:inside"> 列表前面的序号和列表内容在一起
<ol style="list-style:outside">列表前面的序号和列表内容分开
<ol style="list-style-image:url(001.png)">将列表前面的序号变成图片
七、格式和布局
1.位置 position
①fixed固定 相对于浏览器边框位置固定,上下拉滚动条不随着滚动条的上下拖拉而变化。
<div style="width:200px; height:200px; position:fixed; top:"></div>
调整位置:top:距离上边距的位置 right:距离右边距的位置 bottom:距离下边距的位置 left:距离左边距的位置
<div style="width:200px; height:200px; background-color:#03F; position:fixed; top:20px; left:20px"></div>
②absolute 相对于父级元素(浏览器、绝对定位的上级,此处的上级就是<body>)。
<div style="width:200px; height:200px; background-color:#03F; position:absolute; top:100px; left:50px"></div> <div style="width:500px; height:500px; position:absolute; top:100px; left:100px; background-color:#FCC"> <div style="width:200px; height:200px; background-color:#03F; position:absolute; top:100px; left:50px"></div> </div>
上面的代码里面的position的位置是相对于外面那一级的position的位置决定的。但是外面的那一级中也要有position并且值是absolute才可以,否则上一级对里面那一级就失去了约束作用。
③relative 相对位置 相对于原来自身的位置移动
网页上的元素都存在默认的边界(margin或者padding),在网页上布局开始时要把元素自身带的margin或者padding去掉,防止因为元素自身的边界不同而造成布局时各元素发生错乱,去掉方式为。
<title>无标题文档</title>
<style type="text/css">
*{ margin:0px; padding:0px}
</style>
页面布局时一定要加上 *{ margin:0px; padding:0px} 如果 四周的 margin和padding如果一样的话写上一个值就可以。
实际上去掉边界时会写成 *{ margin:0px auto; padding:0px},加上auto里面的元素会水平居中
2.流 float
right 向右流
left 向左流
<style type="text/css">
*{ margin:0px auto; padding:0px}
.text{ width:200px; height:200px; background-color:#63C; margin:0px 0px 0px 10px; float:left}
</style>
</head>
<body>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
使用 流 时,里面的元素会默认的浮上一层,流结束后,要把流清掉,清掉方式是在流结束的位置加上<div style="clear:both"></div>。使用margin时,一般要配合着流使用,自己使用没有效果。
以下代码是一个简单的导航栏
<style type="text/css">
*{ margin:0px auto; padding:0px; font-family:微软雅黑}
#menu{ width:800px; height:45px; background-color:#CCC; margin-top:20px}
.text{ width:100px; height:45px; float:left; text-align:center; line-height:45px; vertical-align:middle}
.text:hover{ background-color:#63C; color:#FFF; cursor:pointer}
</style>
</head>
<body>
<div id="menu">
<div class="text">首页</div>
<div class="text">产品中心</div>
<div class="text">产品介绍</div>
<div class="text">图集</div>
<div class="text">联系我们</div>
<div class="text">友情链接</div>
<div style="clear:both"></div>
</div>
:hover表示鼠标放上来,当鼠标放到这些元素上来以后
.text:hover{ background-color:#63C; color:#FFF; cursor:pointer} 表示把鼠标变成手。background-color:#63C表示鼠标放上后变成的背景色。 color:#FFF表示鼠标放上后文字变成什么颜色。导航栏除了用<div>制作以外,还可以用序列制作。
<style type="text/css">
*{ margin:0px auto; padding:0px; font-family:微软雅黑}
#menu{ width:800px; height:45px; background-color:#CCC; margin-top:20px}
#menu1{width:800px; height:45px; background-color:#CCC; margin-top:20px; list-style:none}
.text{ width:100px; height:45px; float:left; text-align:center; line-height:45px; vertical-align:middle}
.text:hover{ background-color:#63C; color:#FFF; cursor:pointer}
</style> <ul id="menu1">
<li class="text">首页</li>
<li class="text">产品中心</li>
<li class="text">产品介绍</li>
<li class="text">图集</li>
<li class="text">联系我们</li>
<li class="text">联系我们</li>
</ul>
用列表制作的导航栏和用<div>制作的是一样的效果。
<div style="width:300px; height:300px; background-color:#0F0; z-index:3; position:relative"></div> <div style="width:300px; height:300px; background-color:#F00; position:relative; top:-100px; left:-50px; z-index:6"></div>
z-index表示分层,z-index的值越大表示图层越靠上。
八、其它样式
1.display 显示block和隐藏none ,不占位置,隐藏后下面的代码内容会覆盖原来的区域。
2.visibility 显示visible和隐藏hidden ,占位置,隐藏后原来的区域不会被覆盖。
3.overflow 超出范围hidden隐藏,比如两个套着的<div>,如果里面的区域比外面的区域面积大,则外面的<div>区域多出的里面的<div>区域隐藏。
4.opacity 透明 opacity:0.5;-moz-opacity:0.5;filter:alpha(opacity=50) 半透明是0.5
5.border-radius:5px; 圆角 5px是圆角的半径
6.box-shadow阴影 box-shadow:0 0 5px white; 5px是距离上一个<div>的距离,距离越远,阴影面积就越大。white是阴影的颜色。
转载请注明出处,谢谢合作!
http://www.cnblogs.com/xiaofox0018
9月11日上午HTML有序列表、无序列表、网页的格式和布局的更多相关文章
- 8月11日嵌入式Linux开发免费项目体验邀您参与
嵌入式Linux开发免费项目体验开课啦~~我们特意邀请到粤嵌金牌讲师和技术专家,为大家带来精彩有趣的嵌入式公开课,涉及到嵌入式学习.研发的方方面面.课堂中我们能体验到的不仅仅是最新资讯.技术体验,还有 ...
- Yoshua Bengio 2016年5月11日在Twitter Boston的演讲PPT
Yoshua Bengio最新演讲:Attention 让深度学习取得巨大成功(46ppt) Yoshua Bengio,电脑科学家,毕业于麦吉尔大学,在MIT和AT&T贝尔实验室做过博士后研 ...
- 2016年12月11日 星期日 --出埃及记 Exodus 21:6
2016年12月11日 星期日 --出埃及记 Exodus 21:6 then his master must take him before the judges. He shall take hi ...
- 2016年11月11日 星期五 --出埃及记 Exodus 20:2
2016年11月11日 星期五 --出埃及记 Exodus 20:2 "I am the LORD your God, who brought you out of Egypt, out o ...
- 2016年10月11日 星期二 --出埃及记 Exodus 18:22
2016年10月11日 星期二 --出埃及记 Exodus 18:22 Have them serve as judges for the people at all times, but have ...
- 西安Uber优步司机奖励政策(1月11日~1月17日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 2019年IntelliJ IDEA 最新注册码,亲测可用(截止到2020年3月11日)
2019年IntelliJ IDEA 最新注册码(截止到2020年3月11日) 操作步骤: 第一步: 修改 hosts 文件 ~~~ 在hosts文件中,添加以下映射关系: 0.0.0.0 acco ...
- 优步UBER司机全国各地奖励政策汇总 (4月11日-4月17日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 成都Uber优步司机奖励政策(4月11日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
随机推荐
- JS导出PDF插件(支持中文、图片使用路径)
在WEB上想做一个导出PDF的功能,发现jsPDF比较多人推荐,遗憾的是不支持中文,最后找到pdfmake,很好地解决了此问题.它的效果可以先到http://pdfmake.org/playgroun ...
- ubuntu下安装lrzsz
secureCRT中可以使用rz和sz命令上传和下载文件,可是这要linux中安装了lrzsz才可以.我用的时候无法使用apt-get自动安装,下面介绍手动安装的方法. 1 下载lrzsz软件 ht ...
- LLVM 笔记(三)—— 了解传统编译器设计
ilocker:关注 Android 安全(新手) QQ: 2597294287 传统的静态编译器 (如大多数的 C 语言编译器) 通常将编译工作分为三个阶段,分别由三个组件来完成:前端.优化器和后端 ...
- 3、DNS服务器功能(正向、反向解析)
实验目的: 建立gr.org域的主名称服务器.解析: 名称 IP 用途 ns.gr.org 192.168.170.3 名称服务器 www.gr.org 192 ...
- 基于GPUImage的多滤镜rtmp直播推流
之前做过开源videocore的推流改进:1)加入了美颜滤镜; 2) 加入了librtmp替换原来过于简单的rtmpclient: 后来听朋友说,在videocore上面进行opengl修改,加入新的 ...
- docker
docker pull centos docker images docker run -ti centos cat /etc/redhat-release ##################### ...
- [django]Django的css、image和js静态文件生产环境配置
前言:在Django中HTML文件如果采用外联的方式引入css,js文件或者image图片,一般采用<link rel="stylesheet" href="../ ...
- [WPF系列]-DataBinding 枚举类型数据源
public class EnumerationDataProvider : ObjectDataProvider { public Type EnumerationType { get; set; ...
- strus2验证框架
为什么要用验证框架? 当验证规划比较复杂时,Action类的代码江边的非常繁琐,假如我们要对电话号码进行验证,是非常麻烦的. 验证框架的优点 Struts2中内置了一个验证框架,将常用的验证规则进行了 ...
- 在MySQL中出现Unknown column 'abc' in 'field list'怎么解决?
update TABLE1 set NAME = '?' where ID ='?' 参数字段需要添引号.