CSS 案例学习
1.样式 display:inline-block;可改变a标签,合其可定义宽高
2.a:hover表示鼠标经过
3.background:url(110.png) bottom 表示:给链接一个图片 并底端对齐 代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
a{
display: inline-block;
width:67px;
height:32px;
background: url("110.png"); } a:hover{
background: url(110.png) bottom;
}
</style>
<title></title>
</head>
<body>
<a href="#"></a> </body>
</html>
4.text-align:center 水平剧中
5.一行文字行高与父元素等高时 文字垂直居中
6.text-decoration:none去掉下划线
eg:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
a{
display: inline-block;
width: 120px;
height: 58px;
text-align: center;
text-decoration: none;
color: white;
line-height: 50px; } a.one{
background: url(images/bg1.png);
}
a.two{
background: url(images/bg2.png);
} a.three{
background: url(images/bg3.png);
}
a.four{
background: url(images/bg4.png);
} a:hover{ background: url(images/bg6.png) } }
</style>
<title></title>
</head>
<body>
<a href="#" class="one">五彩导行</a>
<a href="#" class="two">五彩导行</a>
<a href="#" class="three">五彩导行</a>
<a href="#" class="four">五彩导行</a>
</body>
</html>
效果:
7.padding 学习
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.nav{ height: 40px;
background: #eee;
border-top: 3px solid orange;
border-bottom: 1px solid #aaa
}
.nav-con{
width:1000px;
height: 40px;
margin: 0 auto;
line-height: 40px;
}
a{ display: inline-block;
height: 40px;
color:#aaa;
font:12px/40px 微软雅黑;
text-decoration: none;
padding: 0 12px;
} a:hover{
background: #999;
}
</style>
<title></title>
</head>
<body>
<div class="nav">
<div class="nav-con">
<a href="#">设为首页</a>
<a href="#">手机新浪网</a>
<a href="#">移动客户端</a>
</div>
</div>
</body>
</html>
效果:
8.列表
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.news{
width: 238px;
height: 166px;
border:1px solid #d9e0ee;
border-top: 3px solid #ff8400;
margin: 0 auto;
} .news-title{
height: 35px;
border-bottom: 1px solid #d9e000;
line-height: 35px;
padding-left: 12px;
}
ul{
margin-top: 12px;
}
ul,li{
list-style: none;
margin: 0;
padding: 0;
}
li{
padding-left: 12px;
background: url("li_bg.jpg") no-repeat
9px 7px;
font: 14px 微软雅黑;
}
</style>
</head>
<body>
<div class="news">
<div class="news-title">行业动态</div>
<ul>
<li>气质不错</li>
<li>气质不错</li>
<li>气质不错</li>
<li>气质不错</li>
<li>气质不错</li>
</ul> </div>
</body>
</html>
效果:
9.浮动
作用:1.文字环绕图片
2.导航
3布局
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
body,ul,li{
margin: 0;
padding: 0; }
ul,li{
list-style: none;
}
.nav{
width: 800px;
height: 40px;
background: pink;
margin: 20px auto;
} .nav ul li{
float: left; } .nav ul li a{
display: inline-block;
height: 40px;
font: 14px/40px 微软雅黑;
padding: 0 20px ;
text-decoration: none;
} .nav ul li a:hover{
background: #aaa;
} </style>
</head>
<body>
<div class="nav">
<ul>
<li><a href="#">百度</a></li>
<li><a href="#">百度</a></li>
<li><a href="#">百度</a></li>
</ul>
</div>
</body>
</html>
效果:
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
body,ul,li{
margin: 0;
padding: 0;
} li{
list-style: none; } .nav{
height: 55px;
background: url("img/head_bg.jpg");
margin-top: 30px;
border-top: 1px solid #666;
} .nav .nav-con{
width: 1000px;
margin: 0 auto;
height: 55px;
} .nav-con ul li{
float: left;
background: url("img/li_bg.png") no-repeat right;
height: 55px;
padding:0 30px;
} a{
display:inline-block;
height: 55px;
font: 14px/55px 微软雅黑;
text-decoration: none;
color: gray;
} a:hover{
color: green;
} </style>
</head>
<body>
<div class="nav">
<div class="nav-con">
<ul>
<li><a href="#" >智能手机</a></li>
<li><a href="#">平板电脑</a></li>
<li><a href="#" >百度</a></li>
<li><a href="#" >么么么哒</a></li>
</ul>
</div>
</div> </body>
</html>
效果:
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
.header,.main,.footer{
width: 500px;
} .header,.footer{
height: 100px;
background: #000;
margin: 10px 0;
} .main{
height: 300px;
background: #eee;
}
.content{
width: 300px;
height: 300px;
background: orange;
float: left;
} .sidebar{
width: 190px;
height:300px;
background: green;
float: right;
} </style>
</head>
<body> <div class="header"></div>
<div class="main">
<div class="content"></div>
<div class="sidebar"></div> </div>
<div class="footer"></div> </body>
</html>
效果:
10 .清除浮动
1).clear:both 浮动最后加一个标签 样式加这个 清除浮动
2).overflow:hidden 在父盒子里用 当浮动出合子时不可使用
3).clearfix:after{content:"";display:block;height:0;line-height:0;visibility:hidden;clear:both} .clearfix{zoom:1;} 兼容IE 伪元素清除 (常用)最后把这个样式给要清除的父元素
CSS 案例学习的更多相关文章
- css案例学习之table tr th td ul li实现日历
效果 代码 <html> <head> <title>Calendar</title> <style> <!-- .month { b ...
- css案例学习之盒子模型
定义:每个盒子都有:边界.边框.填充.内容四个属性: 每个属性都包括四个部分:上.右.下.左:这四部分可同时设置,也可分别设置:里的抗震辅料厚度,而边框有大小和颜色之分,我们又可以理解为生活中所见盒子 ...
- css案例学习之继承关系
代码 <html> <head> <title>继承关系</title> <style> body{ color:blue; /* 颜色 * ...
- css案例学习之用thead、tbody、tfoot实现漂亮的table布局
首先说说thead.tbody.tfoot <thead> <tbody> <tfoot> 无论前后顺序如何改变, <thead> 内的元素总是在表的最 ...
- css案例学习之ul li dl dt dd实现二级菜单
效果 代码实现 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...
- css案例学习之按钮超链接
效果 css实现 <html> <head> <title>按钮超链接</title> <style> a{ /* 统一设置所有样式 */ ...
- css案例学习之relative与absolute
代码 <!DOCTYPE html PUBliC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.o ...
- css案例学习之float浮动
代码: <!DOCTYPE html PUBliC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3. ...
- css案例学习之父子块的margin
两边还会有些距离,这是body默认的. 代码: <head> <title>父子块的margin</title> <style type="text ...
随机推荐
- jQuery选择器我犯的错误(原创)
jQuery的选择器十分强大,但是在使用jQuery选择器的时候一定要十分小心,空格.冒号.引号到处都是坑,老手也不能避免,只能勤加练习,熟能生巧,掌握规律,为了练习,凡是到选择器的地方我都自己先敲, ...
- yum安装LAMP
安装LAMP环境二进制包安装,先更新yum源,PHP 7.0.33 扩展可选 yum -y install mysql mysql-server mysql-devel httpd httpd-dev ...
- 10-vim-选中命令-01-三种选择文本的方式
选择文本(可视模式) 学习复制命令前,应该先学会如何选中要复制的代码. 在vi中要选择文本,需要先使用visual命令切换到可视模式. vi中提供了三种可视模式. 按ESC可以放弃选中,返回到命令模式 ...
- ArcMap属性表操作接口ITableWindow3
ITableWindow3 tableWindow3 = new TableWindowClass { //Layer = laye ...
- Java面试宝典(1)Java基础部分
Java面试宝典 题目,日积月累,等到出去面试时,一切都水到渠成,面试时就自然会游刃有余了. 答题时,先答是什么,再答有什么作用和要注意什么(这部分最重要,展现自己的心得) 答案的段落分别,层次分明, ...
- SQL中的DDL、DML、DCL、TCL
1.DDL(Data Definition Language)数据库定义语言statements are used to define the database structure or schema ...
- Android 中MediaPlayer播放音频
1.播放/res/raw/目录下的音频资源 public class MainActivity extends Activity { MediaPlayer mediaPlayer; int posi ...
- 8、服务发现&服务消费者Feign
spring cloud的Netflix中提供了两个组件实现软负载均衡调用,分别是Ribbon和Feign.上一篇和大家一起学习了Ribbon. Ribbon :Spring Cloud Ribbon ...
- 使用WdatePicker时间插件简单的控制页面上两个时间选择的前后范围
很多时候我们在一个交互的页面上需要显示两个时间让客户填写,比如开始时间&结束时间,顾名思义开始肯定不能大于结束,故使用WdatePicker插件选择时间的话可以很好的做好时间段的控制.看下面一 ...
- Shell内置命令let