วันพฤหัสบดีที่ 31 มกราคม พ.ศ. 2562

HTML Table

HTML Table
     เป็นการสร้างตารางด้วยภาษา html โดยมีองค์ประกอบคือ
<table> กำหนดให้สร้างตาราง
<th>        สร้างหัวข้อ
<tr>        ขึ้นบรรทัดใหม่
<td>       ขึ้นคอลัมน์ใหม่

ตัวอย่างการใช้งาน <table>


<table align="center" border="1" bgcolor="#FFFF99">
  <tr>
    <td>ลำดับที่</td>
    <td>คำถาม</td>
    <td>วันที่สร้าง</td>
    <td align="right">ตัวเลือก</td>
  </tr>
        {% for question in latest_question_list %}
        <tr>
            <td>{{question.id}}</td>
            <td>{{ question.question_text }}</td>
            <td>{{question.pub_date}}</td>
            <td >
            {% for choice in question.choice_set.all %}
            <input type="radio" name="Choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
            <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
            {% endfor %}
            </td>
         </tr>
        {% endfor %}

</table>

---------------------------------------------------------------------------------------------------------
ผลลัพธ์ที่ได้


นอกจากนี้เรายังสามารถกำหนดคุณสมบัติต่างๆของตารางได้ดังนี้
align="..." กำหนดตำแหน่งของข้อความภายในตาราง
border="…" กำหนดความเข้มของเส้นขอบตาราง
width="…%" กำหนดความกว้างของตาราง
height="…%" กำหนดความยาวของตาราง
bgcolor="…" กำหนดสีของตาราง
rowspan=" ... " กำหนดการรวมแถว
colspan= " ... " กำหนดการรวมคอลัมน์

Cr : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table

ไม่มีความคิดเห็น:

แสดงความคิดเห็น