2024年3月31日 星期日

在pythonanywhere設計Django網站的卡片(Card)功能

 




修改mysite/templates/vegetable.html程式

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
  {% load bootstrap5 %}
  {% bootstrap_css %}
  {% bootstrap_javascript %}
  {% load static %}
</head>
<body>
<div class="container">
  <ul class="nav bg-info">
    <li class="nav-item">
      <a class="nav-link link-light" href="/">首頁</a>
    </li>
    <li class="nav-item">
      <a class="nav-link link-light" href="/vegetable/">蔬菜</a>
    </li>
    <li class="nav-item">
      <a class="nav-link link-light" href="/fruit/">水果</a>
    </li>
  </ul>

<h1>蔬菜</h1>
<div class="row">
    <div class="card" style="width:300px">
        <img class="card-img-top" src={% static "images/vegetable01.jpg" %} alt="Card image">
        <div class="card-img-overlay">
            <h4 class="card-title" style="color:white;">蔬菜01</h4>
            <p class="card-text" style="color:white;">好蔬菜在雲林</p>
            <a href="#" class="btn btn-primary">說明</a>
        </div>
    </div>
    <div class="card" style="width:300px">
        <img class="card-img-left" src={% static "images/vegetable02.jpg" %} alt="Card image">
        <div class="card-img-overlay">
            <h4 class="card-title" style="color:white;">蔬菜02</h4>
            <p class="card-text" style="color:white;">好蔬菜在雲林</p>
            <a href="#" class="btn btn-primary">說明</a>
        </div>
    </div>
    <div class="card" style="width:300px">
        <img class="card-img-top" src={% static "images/vegetable03.jpg" %} alt="Card image">
        <div class="card-img-overlay">
            <h4 class="card-title" style="color:white;">蔬菜03</h4>
            <p class="card-text" style="color:white;">好蔬菜在雲林</p>
            <a href="#" class="btn btn-primary">說明</a>
        </div>
    </div>
    <div class="card" style="width:300px">
        <img class="card-img-top" src={% static "images/vegetable04.jpg" %} alt="Card image">
        <div class="card-img-overlay">
            <h4 class="card-title" style="color:white;">蔬菜04</h4>
            <p class="card-text" style="color:white;">好蔬菜在雲林</p>
            <a href="#" class="btn btn-primary">說明</a>
        </div>
    </div>
</div>
  {% block content %}
  {% endblock %}
</div>
</body>
</html>


沒有留言:

張貼留言