一些實用的Django+HTML設置


一、關於引入變量

1.變量引入方法:

{% block 塊名稱 %}

<p>{{變量名}}<p>

{% endblock %}

 

2.引入變量的值中標簽是否轉義:

不轉義:

{% autoescape off %}

...HTML代碼...

{% endautoescape %}

 

轉義:

{% autoescape on %}

...HTML代碼...

{% endautoescape %}

 

或者部分不轉義部分轉義:

{% autoescape off %}

...HTML代碼...

{% autoescape on %}

...HTML代碼...

{% endautoescape %}

 

 

二、表格數據水平+垂直居中

<td style="text-align:center;vertical-align:middle;margin:auto">表格數據</td>

 

 

三、表格列名跨行顯示

使用 rowspan/colspan 屬性,代表占用多少行/列,以下為代碼和效果圖

代碼:

<table border="1" summary="this table gives some statistics about fruit
   flies: average height and weight, and percentage
     with red eyes (for both males and females).">
    <caption>
        <em>
            A test table with merged cells.
        </em>
    </caption>
    <tbody>
        <tr>
            <th rowspan="2">Gender&nbsp;</th>
            <th colspan="1">Max</th>
            <th colspan="1">Min</th>
            <th rowspan="2">Rate</th>
        </tr>
        <tr>
            <th>Height</th>
            <th>Weight</th>
        </tr>
        <tr>
            <td>Male</td>
            <td>1.9</td>
            <td>100</td>
            <td>40%</td>
        </tr>
        <tr>
            <td>Female</td>
            <td>1.7</td>
            <td>88</td>
            <td>43%</td>
        </tr>
    </tbody>
</table>
<p>

 

簡化的效果圖:

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM