css编写一个自适应的博客页面效果代码

代码语言:html

所属分类:响应式

代码描述:css编写一个自适应的博客页面效果代码

代码标签: 适应 博客 页面 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/font-awesome-4.7.0/css/font-awesome.min.css">
<link href='https://fonts.googleapis.com/css?family=Lato:300,400,700|Poiret+One' rel='stylesheet' type='text/css'>
  
  
  
<style>
/* Base Styles */

body{
	margin: 0;
	padding: 0;
	font-size: 16px;
	line-height: 1.4em;
	color: #222;
	background: #474747;
	font-family: 'Lato', sans-serif;
}

img{
	max-width: 100%;
	height: auto;
	border-radius: 3px;
}

a{
	text-decoration: none;
	color: inherit;
}

/* Grid */

.section {
	clear: both;
	padding: 0;
	margin: 0;
}

.col {
	display: block;
	float:left;
	margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }

.span_3_of_3 {
	width: 100%;
}
.span_2_of_3 {
	width: 66.1%;
}
.span_1_of_3 {
	width: 32.2%;
}

/* Header & Navigation */

header{
	max-width: 100%;
	background: #222; /*FallBack*/
	background: rgba(0,0,0,.6);
	padding: 20px;
}

nav{
	width: 100%;
	margin-bottom: 1em;
	background: #323232;
	font-family: 'Poiret One', cursive;
}

.logo{
	text-align: center;
	color: #fff;
	font-size: 3em;
	font-weight: 400;
	font-family: 'Poiret One', cursive;
}

ul{
	padding: 0;
	margin: 0;
	overflow: hidden;
	color: #fff;
	text-align: center;
	-webkit-transition: max-height 0.5s;
	transition: max-height 0.5s;
}

.nav-item{
	display: inline-block;
	padding: 20px;
	font-size: 1.4em;
	-webkit-transition: background .5s;
	transition: background .5s
}

.nav-item:hover{
	background: #474747;
	cursor: pointer;
}

.menu-bar{
	width: 100%;
	-webkit-box-sizing: border-box;
  -ms-box-sizing: border-box;
  box-sizing: border-box;
	background: #2d2d2d;
	text-align: left;
	padding: 15px 20px;
	color: #fff;
	font-size: 1.4em;
	cursor: pointer;
	display: none;
}

.hamburger-icon{
	float: right;
	clear: both;
	margin-top: -5px;
	font-size: 1.4em;
}

/* Blog Posts */

.container{
	max-width: 1020px;
	margin: 0 auto;
	padding: 20px;
}

.blog-post{
	background: #fff;
	margin: 0 auto 2em auto;
	padding: 35px 30px;
	box-shadow: 5px 5px 15px -1px rgba(0,0,0,0.3);
}

.side-post{
	background: #fff;
	margin: 0 auto 1.5em auto;
	width: 15em;
	padding: 20px;
}

.blog-content{
	font-size: 1em;
	border-left: 5px solid #8EE5EE;
	padding-left: 15px;
}

.side-content{
	font-size: .9em;
	margin-top: 8px;
	margin-bottom: 0;
}

.blog-title{
	font-size: 2.5em;
	margin-top: 5px;
}

.date{
	font-size: 1em;
	font-weight: 400;
	color: #9C9C9C;
	margin-top: -10px;
	text-decoration: underline;
	text-decoration-color: currentColor;
}

.post-link{
	color: #009ACD;
	font-style: italic;
	transition: all 0.4s;
}

.post-link:hover{
	color: #005c7b;
	text-decoration: underline;
	text-decoration-color: currentColor;
	cursor: pointer;
}

/* Button */

.button{
	display: block;
	padding: 15px 20px;
	margin-top: .8em;
	background: #009ACD;
	text-align: center;
	color: #fff;
	font-size: 1.4em;
	border-radius: 3px;
	transition: all .4s ease-in;
}

.button:hover{
	background: #005c7b;
}

/*Media Queries*/

/* @900px*/
@media only screen and (max-width: 56.25em) {
	.col{ margin: 1% 0 1% 0%;}
	.span_3_of_3, .span_2_of_3, .span_1_of_3{ width: 100%; }
	.side-post{ width: 42%;
			   float: left;
			   margin: -2% 0 1% 1.6%;}
}

/* @685px*/
@media only screen and (max-width: 42.813em) {
	.side-post{ width: auto;
				padding: 15px;
			    margin: -2% auto 8% auto; }
	.blog-title{ font-size: 1.95em; }
	.date{ font-size: .9em; }		
}

/* @480px */
@media only screen and (max-width: 30em){
	nav ul{ max-height: 0; }
	.reveal{ max-height:19em; }
	nav ul .nav-item{ -webkit-box-sizing: border-box;
		 			  -moz-box-sizing: border-box;
     				  -ms-box-sizing: border-box;
        			  box-sizing: border-box;
					  width:100%;
		 			  padding: 15px; }
	
	.menu-bar{ display: block; }

}

/* @380px*/
@media only screen and (max-width: 23.75em) {
	.blog-content, .post-link{ font-size: .9em; }
	.side-content{ font-size: .8em; }
	.button{ padding: 10px 15px; }
	.nav-item{ font-size: 1.2em; }
}
</style>




</head>

<body >
  <header>
		  <h1 class="logo">Logo</h1>
	</header>
	
	<nav>
  			<ul>
				    <li class="nav-item"><a href="#" >Home</a></li>
				    <li class="nav-item"><a href="#" >Blog</a></li>
				    <li class="nav-item"><a href="#">About</a></li>
    				<li class="nav-item"><a href="#" >Contact</a></li>
			  </ul>
				  <div class="menu-bar">Menu
					    <span class="hamburger-icon&q.........完整代码请登录后点击上方下载按钮下载查看

网友评论0