Hướng dẫn thiết kế Bố cục các tiện ích (widget) trong Blogspot
Hình minh họa khi thiết kế bố cục tiện ích
![Hướng dẫn thiết kế Bố cục các tiện ích (widget) trong Blogspot](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfWZo9s6AU5UQX-WXCFAbf7PeGQpc82k1z35Lo81mF_IqZNi7kzhxoUCBfq0RzR_COosDh_nBHqpDtQUKmS5mCWeZPEevE9BhN4wy6_EZvyyu5N2vHZg36hMPK7LLZbKI95Ax0JZRcecHb/s320/2018-06-10_13-24-25.jpg)
![Hướng dẫn thiết kế Bố cục các tiện ích (widget) trong Blogspot](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh1SA1Xg37mU5llXswV4UQ_799qqZ0-sInioU1uMaD34EOASYoBw28GOJtr47NxgPcYh_cJJ1rYqeA55E8MslfbkUoLI31ACTxupmntS3WV95IITHpevMSO9STf1qSrv52Hj84e2FphgtX/s320/2018-06-10_13-24-56.jpg)
![Hướng dẫn thiết kế Bố cục các tiện ích (widget) trong Blogspot](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLH_nJUmGi6EumYAXFM-ugseO5bBFkjisbO87TUtwjegVGMX3l75onaIoHQTVdDiBzs8FeeK3KRsl9tMIj542uGlztGKOzFZIcw78wE9Nr-dbb3GFW5gaWr_6Kg6gRAngJb1LjThWxNHR2/s320/2018-06-10_13-25-34.jpg)
Về căn bản giao diện của Blog bạn cứ phân ra làm 3 phần: Đầu trang (Header), Thân trang (Page Body) và Chân trang (Footer) Chẳng hạn tôi sẽ thiết kế bố cục tiện ích bào gồm các tiện ích như sau:
+ Đầu trang (Header): Tôi tạo 3 section
- 1 section để thêm 2 tiện ích header logo bên trái và 1 tiện ích HTML bên phải chèn mã quảng cáo.
- 1 section thêm 1 tiện ích Liên kết để tạo menu
- 1 section thêm 1 tiện ích HTML đặt mã quảng cáo
+ Thân trang (Page Body) tôi tạo 3 section:
- 1 Section bên trái đặt tên Main Wrapper lưu tiện ích Blog1 và các tiện ích khác
- 1 Section bên phải đặt tên Sidebar lưu các tiện ích PopularPost, HTML đặt mã quảng cáo
- 1 section dưới chân thêm tiện ích HTML đặt mã quảng cáo chân trang
+ Chân trang (Footer) tôi chia đều ra làm 3 cột với 3 section và với với mỗi section tôi sẽ thêm các tiện ích.
Như vậy tôi đã viết nháp ra ý tưởng, tiêp theo tôi cần đặt tên các id và class cho các vùng để lưu trữ các section, tôi sẽ viết nháp như sau:
+ Đầu tiên tôi sẽ sử dụng 1 class chung lấy đồ rộng đều nhau cho cả 3 phần với thuộc tính max-width ví dụ tôi lấy class .container {max-width:1128px;margin:auto}
+ Tiếp theo tôi sẽ đặt HTML theo ý tưởng thiết kế như sau:
- Phần đầu trang (Header)
<header id='header-wrapper'>
<div class='container'>
<!-- section 1 đặt tiện ích logo và tiện ích HTML1 đặt quảng cáo bên phải -->
<b:section class='header' id='header' name='Header' showaddelement='fasle'>
<b:widget id='Header1' title='' lock='true' title='' type='Header'>...</b:widget>
<b:widget id='HTML1' locked='true' title='' type='HTML' >...</b:widget>
</b:section>
</div>
</header>
<section class='container'>
<!-- section 2 đặt tiện ích Danh sách liên kết tạo menu -->
<b:section id='menu' name='Menu' showaddelement='fasle'>
<b:widget id='LinkList1' locked='true' title='Menu' type='LinkList' >...</b:widget>
</b:section>
</section>
<section class='container'>
<!-- section 3 đặt tiện ích HTML2 chèn mã quảng cáo đầu trang ngay trên bài viết -->
<b:section id='top-banner' name='Quảng cáo đầu trang' showaddelement='fasle'>
<b:widget id='HTML2' locked='true' title='' type='HTML' >...</b:widget>
</b:section>
</section>
- Phần thân trang
<section class='container'>
<!-- section 1 lưu tiện ích Blog1 và các tiện ích khác bên trái -->
<b:section class='main-wrapper' id='main' name='Page Body' showaddelement='true'>
<b:widget id='Blog1' locked='true' title='Bài đăng trên Blog' type='Blog' version='1'>...</b:widget>
<b:widget id='HTML3' locked='true' title='' type='HTML' >...</b:widget>
...
</b:section>
<!--section 2 bên phải lấy tên Sidebar lưu các tiện ích -->
<b:section class='sidebar-wrapper' id='sidebar' name='Sidebar' showaddelement='true'>
<b:widget id='PopularPosts1' locked='true' title='Phổ biến' type='PopularPosts' version='1'>...</b:widget>
<b:widget id='HTML4' locked='true' title='' type='HTML' >...</b:widget>
....
</b:section>
<!-- section 3 lưu tiện ích HTML đặt mã quảng cáo chân trang -->
<b:section id='qc_bottom' name='Quảng cáo chân trang' showaddelement='false'>
<b:widget id='HTML5' locked='true' title='' type='HTML' >...</b:widget>
</b:section>
</section>
- Chân trang tạo 3 section lưu tiện ích
<footer id='footer'>
<div class="container">
<!-- section 1 -->
<b:section class='footer' id='footer1' name='Footer 1' showaddelement='true'>
<b:widget id='HTML6' locked='true' title='' type='HTML' >...</b:widget>
</b:section>
<!-- section 2 -->
<b:section class='footer' id='footer2' name='Footer 2' showaddelement='true'>
<b:widget id='HTML7' locked='true' title='' type='HTML' >...</b:widget>
</b:section>
<!-- section 3 -->
<b:section class='footer' id='footer2' name='Footer 3' showaddelement='true'>
<b:widget id='HTML8' locked='true' title='' type='HTML' >...</b:widget>
</b:section>
</div>
</footer>
Khi đặt bố cục tiện ích xong khi tải trang cho ra HTML khi kiềm tra phần tử như sau:
<!-- Đầu trang -->
<header id="header-wrapper">
<div class="container">
<div class="header" id="header" name="Tiêu đề">
<div class="widget Header" id="Header1">...</div>
<div class="widget HTML" id="HTML1">...</div>
</div>
</header>
<!-- Menu -->
<section class="container">
<div class="section" id="menu" name="Menu">
<div class="widget LinkList" id="LinkList1">...</div>
</div>
</section>
<!-- Quảng cáo đầu trang -->
<section class="container">
<div class="section" id="top-banner" name="Quảng cáo đầu trang">
<div class="widget HTML" id="HTML2">...</div>
</div>
</section>
<!-- Thân trang -->
<section class="container">
<div class="main-wrapper section" id="main" name="Phần chính của trang">
<div class="widget Blog" data-version="1" id="Blog1">...</div>
<div class="widget HTML" id="HTML3">...</div>
</div>
<div class="sidebar-wrapper section" id="sidebar" name="Thanh bên">
<div class="widget PopularPosts" data-version="1" id="PopularPosts1">...</div>
<div class="widget HTML" id="HTML4">...</div>
</div>
<div class="section" id="qc_bottom" name="Quảng cáo chân trang">
<div class="widget HTML" id="HTML5">...</div>
</div>
</section>
<!-- Chân trang -->
<footer id='footer'>
<div class="container">
<div class="footer section" id="footer1" name="Footer 1">
<div class="widget HTML" id="HTML6">...</div>
</div>
<div class="footer section" id="footer2" name="Footer 2">
<div class="widget HTML" id="HTML7">...</div>
</div>
<div class="footer section" id="footer3" name="Footer 3">
<div class="widget HTML" id="HTML8">...</div>
</div>
</div>
</footer>
+ Thiết kế css cho các id và class
Đặt các id và class này trong <b:skin> ví dụ:
<b:skin><![CDATA[
#header-wrapper {}
...
]]></b:skin>
và đặt bốc cục ngoài trong <b:template-skin>
<b:template-skin><![CDATA[
body#layout #header-wrapper {}
...
]]></b:template-skin>