DIV CSS 佈局教程網

用 HTML5 做一個留言與回覆的頁面樣式
編輯:關於JavaScript     

留言列表的樣式不難,難在細節:頭像與暱稱的層級、時間的弱化、回覆內容的視覺區隔、長文字換行。以下這份結構直接可跑,貼進編輯器就能看到效果。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>留言與回覆</title>
<style type="text/css">
*{
  margin:0; padding:0;
  -webkit-touch-callout: none;        /* 避免長按選取圖片 */
  -webkit-text-size-adjust: none;     /* 避免文字被自動縮放 */
  -webkit-tap-highlight-color: rgba(210,210,210,0.35);
  -webkit-user-select: none;          /* 需要複製時改為 text */
}
body{font-family:"微軟雅黑"; font-size:12px;}
ul,li{list-style:none;}
.ylcon{width:100%; min-width:320px;}
.tit{
  height:26px; line-height:26px; padding:0 15px; position:relative;
  font-size:15px; color:#aaa; border-bottom:1px solid rgba(0,0,0,0.15);
}
.story{border-bottom:1px dashed #cecece; padding:0 15px 3px; position:relative;}
.story_t{font-size:1.2em; color:rgba(0,0,0,1); padding-top:5px; padding-bottom:2px;}
.story_m{
  color:rgba(110,110,110,1); line-height:21px;
  word-break:break-all; word-wrap:break-word; overflow:hidden;
  font-size:1.2em; padding:2px 0;
}
.story_time{color:rgba(154,154,154,1); padding:2px 0;}
.story_hf{
  background:rgb(245,245,245); font-size:1.2em;
  border:1px solid rgba(204,204,204,0.2); border-radius:2px;
  color:rgba(110,110,110,1); padding:4px; margin-bottom:5px;
}
.opbtn{position:absolute; top:0; right:0;}
</style>
</head>
<body>
<div class="ylcon">
  <p class="tit">所有留言</p>
  <div id="messDivId">
    <div class="story">
      <div class="opbtn"></div>
      <p class="story_t">憐星</p>
      <p class="story_time">2015/07/12 20:48</p>
      <p class="story_m">想問最近很火的那個團體,他們的八卦呢?</p>
      <p class="story_hf">@劍花煙雨:是那種相對無言、眼波如流的默契。</p>
    </div>
    <div class="story">
      <div class="opbtn"></div>
      <p class="story_t">劍花煙雨</p>
      <p class="story_time">2015/07/12 21:03</p>
      <p class="story_m">樓上說的沒錯,那份默契真的很少見。</p>
      <p class="story_hf">@憐星:同感,我也在追。</p>
    </div>
  </div>
</div>
</body>
</html>

幾個可以沿用的設計決定:.story 用虛線分隔而非實線,視覺上更輕;.story_hf 以淺灰底加圓角做出「引用上一則」的層次;.story_m 加上 word-break:break-all 與 word-wrap:break-word,使用者貼一串沒空格的網址也不會撐破版面。.opbtn 預留絕對定位的右上角,之後放「回覆」按鈕即可。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved