首页 > 代码库 > H5+css从入门到精通

H5+css从入门到精通

当然css代码很多,不可能这么快就精通的,我们只能慢慢来
css层叠样式表是嵌套在html代码内部的

一般格式都是<style> type="text/css"
                          #siderRight {
                             float:left;
                             width:200px;
                             height=300px;
                        }


                        </style>


这里有个老旧html  css代码的对比

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
#header,#siderLeft,#siderRight,#footer{
	border:solid 1px #666;
	padding:10px;
	margin:6px;
}
#header {width:500px}
#siderLeft{
	float:left;
	width:60px;
	height:100px;
}
#siderRight{
	float:left;
	width:406px;
	height:100px
}
#footer{
	clear:both;
	width:500px;
}
</style>
</head>
<body>
<div id="header">导航</div>
<div id="siderLeft">菜单</div>
<div id="siderRight">内容</div>
<div id="footer">底部说明</div>
</body>
</html>

这里是新的html  css代码

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
header,nav,article,footer{
	border:solid 1px #666;
	padding:10px;
	margin:6px;
}
header {width:500px}
nav{
	float:left;
	width:60px;
	height:100px;
}
article{
	float:left;
	width:406px;
	height:100px
}
footer{
	clear:both;
	width:500px;
}
</style>
</head>
<body>
<header>导航</header>
<nav>菜单</nav>
<article>内容</article>
<footer>底部说明</footer>
</body>
</html>

这里我们来发现一个超链接引用css文件的方式和h5里面引用css里面定义的类的一般格式

  <!-- Custom styles for this template -->
    <link href="http://www.mamicode.com/css/dashboard.css" rel="stylesheet">
  </head>

  <body>
    <nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
      <button class="navbar-toggler hidden-md-up" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"></button>
      <div class="collapse navbar-toggleable-sm" id="navbar">
        <a class="navbar-brand" href="http://www.mamicode.com/#">运维工具</a>




本文出自 “11876896” 博客,请务必保留此出处http://11886896.blog.51cto.com/11876896/1896632

H5+css从入门到精通