用CSS實現基本條狀圖表效果

來源:互聯網
上載者:User

CSS條狀圖表是我們在網頁設計中常常會遇到的一種形式。條狀圖表可以將數量,以條狀圖形的形式直觀的表示出來。
  CSS基本條狀圖表的實現方法是什嗎?我們看下面的執行個體介紹: 複製代碼 代碼如下:<div class="graph">
<strong class="bar" style="width: 24%;">24%</strong>
</div>

這是xhtml代碼,定義了一個容器,應用類graph,其中包括了一個xhtml元素strong,並且對這個元素應用類bar。
  我們看下面的CSS定義: 複製代碼 代碼如下:.graph {
position: relative; /* IE is dumb */
width: 200px;
border: 1px solid #B1D632;
padding: 2px;
}
.graph .bar {
display: block;
position: relative;
background: #B1D632;
text-align: center;
color: #333;
height: 2em;
line-height: 2em;
}
.graph .bar span { position: absolute; left: 1em; }

通過上面的邊框,顏色的定義,我們勾勒出了一個條狀的圖形,我們在xhtml代碼中style="width: 24%;",定義了所設定的地區既大小。這樣一個基本的條狀圖表就完成了!
  我們看最終的運行效果: xmlns="http://www.w3.org/1999/xhtml">


24% 60%

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.