Sublime 快捷键:
文件保存后,输入 html:xt + tab ,补全html
html:xt
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Document</title>
</head>
<body>
</body>
</html>
补全class
div.nav + tab =
<div class="nav"><div>
输入多行<a> 标签
a[#]*3 + tab
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
案例:
模仿新浪首页
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<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{
font:12px/40px 微软雅黑;/* 文字大小 行高 */
color: #333;
display: inline-block;
height: 40px;
text-decoration: none;
}
a:hover{
background: #999;
}
</style>
</head>
<body>
<div class="nav">
<div class="nav-con">
<a href="#">设为首页</a>
<a href="#">手机新浪网</a>
<a href="#">移动客户端</a>
</div>
</div>
</body>
</html>
外边距塌陷
嵌套的盒子,直接给子盒子设置垂直方向外边距的时候,会发生外边距塌陷。
解决方法:
1.给父盒子设置边框;
2.给父盒子设置 overflow:hidden bfc 格式化上下文。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style type="text/css">
.father{
width: 500px;
height: 400px;
background: #232323;
border: 1px solid #232323;
}
.son{
width: 200px;
height: 200px;
background: #eee;
margin-top: 50px;
}
</style>
</head>
<body>
<div class="father">
<div class="son">
</div>
</div>
</body>
</html>