更改边距和卡片之间的边距大小

Change margins size between side and cards

晚上好! 我使用 bootstrap 连续创建了 3 张卡片,但我无法更改边距并创建更宽的卡片。 希望下面的图片能表达我的意思。

{% for post in object_list %}
{% if post.status == 1 %}
{% if forloop.counter0|divisibleby:3 %} <div class="row"> {%  endif %}
  <div class="col-md-4">
      <div class="card article">
          <a href="{{ post.get_absolute_url }}"><img class="responsive opacity" src="{{ post.img.url }}" alt=""></a>
          <div class="card-content">
            <p class="author">{{ post.created_on|date:"d.m.y" }} / {{post.field}}</p>
              <h2 class="article-title"><a class="link-article" href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
              <div class="content">
                {{ post.content|safe|truncatewords:45 }}
              </div>
              <div class="button-wrapper"><a href="{{ post.get_absolute_url }}"><button class="button button1" >Czytaj dalej</button></a></div>
              <br>
          </div>
      </div>
  </div>
{%  if forloop.counter|divisibleby:3 or forloop.last %}</div> <br>{%  endif %}
{%  endif %}
{%  endfor %}

尝试在卡片 class 中添加 padding-left 和 right。

CSS


/* ############ NAVBAR ############ */

.navbar {
  background-color: white;
  top: 0; 
  width: 100%;
  transition: top 0.3s;
  margin: 0 auto;
  position: fixed;
  z-index: 999;
}

.nav-link {
    margin-left: 50px;
}

.nav-link:hover {
    color: grey;
}


.navbar a {
  font-family: 'Raleway', sans-serif;
  float: left;
  display: block;
  color: black;
  text-align: center;
  padding: 15px;
  text-decoration: none;
}

.navbar-nav li:hover .dropdown-menu {
    display: block;
}

.dropdown-menu > li > a:hover:after {
    text-decoration: underline;
    transform: rotate(-90deg);
} 

#dropdown-item {
  text-align: left;
  font-size: 0.9rem;
}

#searchform {
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    transition: all 1s;
    width: 50px;
    height: 50px;
    background: white;
    box-sizing: border-box;
    border-radius: 25px;
    border: 4px solid white;
    padding: 5px;
}

#searchform input{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;;
    height: 42.5px;
    line-height: 30px;
    outline: 0;
    border: 0;
    display: none;
    font-size: 1em;
    border-radius: 20px;
    padding: 0 20px;
}

#searchform .fa{
    box-sizing: border-box;
    padding: 10px;
    width: 42.5px;
    height: 42.5px;
    position: absolute;
    top: 0;
    right: 0;
    border-radius: 50%;
    color: #07051a;
    text-align: center;
    font-size: 1.2em;
    transition: all 1s;
}

#searchform:hover{
    width: 200px;
    cursor: pointer;
}

#searchform:hover input{
    display: block;
    background-color: black;
    color:white;
}

#searchform:hover .fa{
    background: #07051a;
    color: white;
}

@media only screen AND (max-width: 1155px) {
  #searchform {
    display: none;
  }
}

/* ############ MAIN ############ */

body {
    background: #f9f6f5;
}

.container {
  font-family: 'Lato', sans-serif;
  margin:90px auto;
}

.article {
  border-color: white;
}
.responsive {
  width: 100%;
  height: auto;
}
.author {
  color:grey;
  font-size: 0.8rem;
  font-family: 'Lato', sans-serif;
  margin: 15px 0px 10px 0px;
  text-align: center;
}
.article-title {
  font-family: 'Oswald', sans-serif;
  text-align: center;
  font-size:28;
}
.link-article {
  color:black;
  text-decoration: none;
}
.link-article:hover {
  color:#EF997F;
  text-decoration: none;
  transition-duration: 0.4s;
}
div.content {
  padding: 0 15px 0 15px;
}
.button-wrapper {
  text-align:center;
}
.button1 {
  background-color: white;
  color: #EF997F;
  border: 1px solid #EF997F;
  transition-duration: 0.4s;
  padding:5px 10px 5px 10px;
}

.button:hover {
  background-color: #EF997F; /* Green */
  color: white;
  cursor:pointer;
}
img.opacity:hover {
  transition-duration: 0.5s;
  opacity: 0.7;
}

更新 我发现 .container 的宽度为 1140 像素,所以我需要额外添加 css 来放大它

@media only screen and (min-width : 1200px) {
    .container { max-width: 1400px; }
}