HTML5和CSS3扁平化風格博客

效果:

wKioL1eTIkOCwGbPAA24_W93PRg492.png-wh_50

wKiom1eTIkSBr51aAAAzNhVD0-0375.png-wh_50

wKioL1eTIkriR_JJAA2-1wHjA9c554.png-wh_50

wKiom1eTIk7hwVXHAAh-SCe1_F8321.png-wh_50

wKiom1eTIk-jLYgxAAEE8pprack897.png-wh_50

wKioL1eTIk-R5pvxAAAIJZrC99U023.png-wh_50

代碼:

html結果

<!DOCTYPE html>

<html>

<head>

<title></title>

<meta charset="utf-8" />

<link rel="stylesheet" type="text/css" href="https://necolas.github.io/normalize.css/3.0.2/normalize.css">

<link rel="stylesheet" type="text/css" href="main.css">

</head>

<body>

<div class="main-wrapper">

<!-- 頁頭 S -->

<header>

<nav>

<div class="logo"><a href="">素顏豬</a></div>

<ul>

<li><a href="">首頁</a></li>

<li><a href="">圖書</a></li>

<li><a href="">相冊</a></li>

<li><a href="">視頻</a></li>

<li><a href="">音樂</a></li>

</ul>

</nav>

<div id="banner">

<div class="inner">

<h1>素顏豬</h1>

<p>

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

</p>

<button>瞭解我</button>

<div class="more">

更多

</div>

</div>

</div>

</header>

<!-- 頁頭 E -->


<!-- 內容 S -->

<div class="content">

<section class="green-section">

<div class="wrapper">

<h2>標題</h2>

<div class="hr"></div>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div class="icon-group">

<span class="icon">item1</span>

<span class="icon">item2</span>

<span class="icon">item3</span>

</div>

</section>

<section class="gray-section">

<div class="article-preview">

<div class="img-section">

<img src="imgs/fj1.jpg">

</div>

<div class="text-section">

<h2>標題</h2>

<div class="sub-heading">副標題</div>

<p>Lorem roident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

</div>

<div class="article-preview">

<div class="text-section">

<h2>標題</h2>

<div class="sub-heading">副標題</div>

<p>Lorem roident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div class="img-section">

<img src="imgs/fj2.jpg">

</div>

</div>

<div class="article-preview">

<div class="img-section">

<img src="imgs/fj3.jpg">

</div>

<div class="text-section">

<h2>標題</h2>

<div class="sub-heading">副標題</div>

<p>Lorem roident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

</div>

</section>

<section class="purple-section">

<div class="wrapper">

<div class="heading-wrapper">

<h2>標題</h2>

<div class="hr"></div>

<div class="sub-heading">

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

</div>

</div>

<div class="card-group clearfix">

<div class="card">

<h3>標題</h3>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div class="card">

<h3>標題</h3>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div class="card">

<h3>標題</h3>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div class="card">

<h3>標題</h3>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

</div>

</div>

</section>

</div>

<!-- 內容 E -->


<!-- 頁腳 S -->

<footer>

<ul class="share-group">

<li>item1</li>

<li>item1</li>

<li>item1</li>

<li>item1</li>

</ul>

<div class="copy">&copy;素顏豬</div>

</footer>

<!-- 頁腳 E -->

</div>

</body>

</html>

css樣式

/*頁頭style S*/

nav{background:transparent;height: 50px}

#banner{background: transparent;height: 500px}


nav ul{list-style: none;margin: 0;float: right;}

nav ul li,nav .logo{display: inline-block;line-height: 50px;margin-right: 20px;}

nav ul li a,nav .logo a{line-height: inherit;text-decoration: none; display: inline-block;height: inherit;color: #fff}

nav .logo{float: left;font-size: 20px;font-weight: bold;letter-spacing: 2px;}

#banner .inner{max-width: 300px;text-align: center;margin: 0 auto;position: relative;top: 80px}

#banner .inner h1{margin:0;}


button{border: none;background:#333;color: #eee;padding: 10px}

#banner .inner .more{margin-top: 80px}

/*頁頭style E*/


/*內容style S*/

.green-section{text-align: center;background:#089DB0;color: #fff;padding: 100px 0;}

.wrapper{max-width: 1080px;margin: 0 auto;}

.hr{width: 100%;height: 2px; margin:20px auto;}

.green-section .hr{background: #078494;width: 50%;}

.icon-group{margin-top: 40px;}

.green-section .icon-group .icon{display: inline-block;width: 80px;height: 80px;background: #0D6F7C;transform:rotate(45deg);margin:20px;}



.gray-section{background:#252f34;color: #fff}

.gray-section .img-section {width: 40%;}

.img-section img{width: 100%}

.gray-section .text-section{width: 60%;}

.article-preview > div{float: left;font-size: 0px}

.article-preview:nth-child(odd){background-color: rgba(255,255,255,0.05);}

.article-preview:after{content: '';clear: both;display: block;}

.text-section{position: relative;top: 60px;left: 50px;}

.text-section h2{margin-bottom: 20px;}

.text-section .sub-heading{font-size: 22px;margin-top: 0px}

.text-section p{font-size: 18px;letter-spacing: 1px;}

.text-section > *{max-width: 90%;}



.purple-section{background:#3f3965;color: #fff;padding: 80px;}

.purple-section .heading-wrapper{text-align: center;}

.heading-wrapper .hr{background:#373259;width: 50%}

.card{float: left;width: 50%;min-height: 300px;padding: 50px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;/*border: 1px solid white*/}

.clearfix:after{content: '';clear: both;display: block;}

.card p{font-size: 18px;letter-spacing: 1px;}

.card:first-child{background:rgba(0,0,0,0.05);}

.card:nth-child(2){background:rgba(0,0,0,0.09);}

.card:nth-child(3){background:rgba(0,0,0,0.14);}

.card:nth-child(4){background:rgba(0,0,0,0.18);}


/*內容style E*/


/*頁腳style S*/

footer{background:#333;color: #fff;min-height: 200px;text-align: center;}

ul.share-group{display: block;width: 1080px;margin: 0 auto;padding: 30px}

.share-group li{display: inline-block;padding: 10px}

.copy{padding: 20px}

/*頁腳style E*/


.main-wrapper{background:#444 url(imgs/cwz3.jpg);background-attachment: fixed;background-repeat: no-repeat;background-size: cover;background-position: center;}

本文轉自  素顏豬  51CTO博客,原文鏈接:http://blog.51cto.com/suyanzhu/1829121