首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有卡片的HTML div响应式设计

带有卡片的HTML div响应式设计
EN

Stack Overflow用户
提问于 2021-05-25 00:32:45
回答 1查看 26关注 0票数 1

标题并没有真正描述我的问题。我有一个web应用程序,上面有“卡片”来描述我的商品,但我需要它来填满屏幕,同时保持不变的大小。

我现在的设计是这样的:current design

我希望我的设计是这样的:design that I want

请原谅我糟糕的图形设计技巧,并提前感谢!

编辑:当前代码

代码语言:javascript
复制
<div class="row">
        {% for task in tasks %}
              <div class="card">
                <div class="alert">
                    <strong>Status: </strong> {{ task.status }}
                </div>
                {% if logo == False %}
                <img src="[redacted]" alt="Logo for {{ task.content }}" style="width:100%">
                {% else %}
                <img src="{{ task.logo }}" alt="Logo for {{ task.content }}" style="width:50%">
                {% endif %}
                <h1>{{ task.content }}</h1>
                <p>{{ task.description }}</p>
                <a href='https://{{ task.website }}'><button>Visit {{ task.content }}'s website</button></a>
                <div class="btn-group"><p><a href='delete/{{ task.id }}'><button style="width:50%">Delete</button></a><a href='update/{{ task.id }}'><button style="width:50%">Edit</button></a></p></div>
              </div>
              <br>
        {% endfor %}
    {% endif %}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-25 02:04:04

你应该使用css样式表来创建一个类似卡片的结构。下面给出了示例代码。

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
}

/* Float four columns side by side */
.column {
  float: left;
  width: 25%;
  padding: 0 10px;
}

/* Remove extra left and right margins, due to padding */
.row {margin: 0 -5px;}

/* Clear floats after the columns */
.row:after {
  content: "";
  display: table;
  clear: both;
}

/* Responsive columns */
@media screen and (max-width: 600px) {
  .column {
    width: 100%;
    display: block;
    margin-bottom: 20px;
  }
}

/* Style the counter cards */
.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  padding: 16px;
  text-align: center;
  background-color: #f1f1f1;
}
</style>
</head>
<body>

<h2>Responsive Column Cards</h2>
<p>Resize the browser window to see the effect.</p>

<div class="row">
  <div class="column">
    <div class="card">
      <h3>Card 1</h3>
      <p>Some text</p>
      <p>Some text</p>
    </div>
  </div>

  <div class="column">
    <div class="card">
      <h3>Card 2</h3>
      <p>Some text</p>
      <p>Some text</p>
    </div>
  </div>
  
  <div class="column">
    <div class="card">
      <h3>Card 3</h3>
      <p>Some text</p>
      <p>Some text</p>
    </div>
  </div>
  
  <div class="column">
    <div class="card">
      <h3>Card 4</h3>
      <p>Some text</p>
      <p>Some text</p>
    </div>
  </div>
</div>

</body>
</html>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67675745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档