我正在寻找在上校之间增加一个空格,但3格仍排在第4行的位置。我试图为setValues((values) => ({...values, val2: result}));
的女巫增加边距,因为这样做没有用,但将其推离了位置。我也尝试添加填充,但是由于我使用边框,因此填充只会推开边框。我还尝试在.col-style-3
的女巫中添加col-sm-12
可以正常工作,但是该事务随后可以正常工作了,我知道这样做不是正确的方法。关于如何解决此问题的任何建议,我希望各框之间的间距不要超过10-15像素。
这是我的html:
col-sm-4
这是我的样式:
<div class="row">
@foreach (var Site in Model)
{
<a target="_blank" href="@Site.Url">
<div class="col-sm-4 col-style-3">
<img class="CasinoImage" src="~/Content/Img/@Site.ImageName" />
<h2>@Site.Name</h2>
<hr />
<h3>Denne side tilbyder:</h3>
<span class="OfferStyle">
@Site.Bonuses
</span>
<hr />
<div class="ClickMeBox">Hent din bonus nu</div>
@if (@Site.DepositRequired == true)
{
<span class="DepositStyle">INDBETALING ER NØDVENDIGT</span>
}
else
{
<span class="DepositStyle">INGEN INDBETALING NØDVENDIGT!</span>
}
</div>
</a>
}
</div>
答案 0 :(得分:0)
我认为您只需要使宽度的大小减MINUS填充和间距即可。
在下面的示例中,每个div周围有一个0.5rem
边距。如果每个div为33.3%,则它们将退出100%容器,因为边缘空间仍会占用空间。因此,我做到了width: calc((33.3%) - 1rem
。我为边框增加了2px。
查看我的CodePen
答案 1 :(得分:0)
注意:请为此使用引导CSS
.col-xs-4{padding: 0 15px;}
<div class="container">
<div class="row">
<div class="col-xs-4">
<img src="https://fakeimg.pl/350x200/ff0000/000">
</div>
<div class="col-xs-4">
<img src="https://fakeimg.pl/350x200/ff0000/000">
</div>
<div class="col-xs-4">
<img src="https://fakeimg.pl/350x200/ff0000/000">
</div>
</div>
</div>
答案 2 :(得分:0)
我建议让您的div.col-sm-4
容器以div.row
类引导border-0
的子代(从外部容器中删除边框),然后您在锚标记中的div看起来像<div class="col-style-3 border">
。演示:https://codepen.io/chasewoodford/pen/VwwZaQe
答案 3 :(得分:0)
您可以使用此代码
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
<style type="text/css">
body {
margin: 30px 0;
padding: 0;
}
.col-style-3 {
padding: 0px !important;
background-color: #fff;
border: solid 1px #e0e0e0;
border-radius: 5px;
text-align: center;
color: #000;
transition: 0.5s;
}
.col-style-3 > a {
color: #FFFFFF;
text-decoration: none;
}
.col-style-3:hover {
border: solid 1px #bebebe;
box-shadow: 0 5px 10px #adadad;
transition: 0.3s;
}
.CasinoImage {
background-color: #024c32;
width: 100%;
height: 244px;
}
a {
text-decoration: none !important;
outline: none !important;
border: none !important;
box-shadow: none !important;
}
.center {
border-bottom: 1px solid #eeeeee;
padding: 15px;
font-size: 25px;
font-weight: 500;
text-align: center;
margin: 0;
}
.Denneside {
border-bottom: 1px solid #eeeeee;
margin: 0;
padding: 20px;
}
.Denneside h3 {
padding: 0;
font-size: 20px;
font-weight: 500;
text-align: center;
margin: 0 0 10px 0;
}
.Denneside span {
padding: 0;
font-size: 16px;
font-weight: 400;
text-align: center;
margin: 0;
}
.ClickMeBox {
background-color: #ff6a00;
padding: 5px;
font-size: 20px;
font-weight: 700;
color: #FFFFFF;
text-align: center;
text-transform: uppercase;
margin: 10px 0 0 0;
}
.Box {
padding: 5px;
font-size: 12px;
font-weight: 400;
text-align: center;
text-transform: uppercase;
margin:0;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-4 border-0">
<a target="_blank" href="@Site.Url">
<div class="col-style-3 border">
<img class="CasinoImage" src="https://www.w3schools.com/images/picture.jpg" alt="Mountain" />
<h2 class="center">Danske Spil</h2>
<div class="Denneside">
<h3>Denne side tilbyder:</h3>
<span class="OfferStyle">100% Indbetaling + 50 FreeSpins</span>
</div>
<div class="ClickMeBox">HENT DIN BOUNUS NU</div>
<div class="Box">INDBETALING ER NODVENDIGT</div>
</div>
</a>
</div>
<div class="col-sm-4 border-0">
<a target="_blank" href="@Site.Url">
<div class="col-style-3 border">
<img class="CasinoImage" src="https://www.w3schools.com/images/picture.jpg" alt="Mountain" />
<h2 class="center">Danske Spil</h2>
<div class="Denneside">
<h3>Denne side tilbyder:</h3>
<span class="OfferStyle">100% Indbetaling + 50 FreeSpins</span>
</div>
<div class="ClickMeBox">HENT DIN BOUNUS NU</div>
<div class="Box">INDBETALING ER NODVENDIGT</div>
</div>
</a>
</div>
<div class="col-sm-4 border-0">
<a target="_blank" href="@Site.Url">
<div class="col-style-3 border">
<img class="CasinoImage" src="https://www.w3schools.com/images/picture.jpg" alt="Mountain" />
<h2 class="center">Danske Spil</h2>
<div class="Denneside">
<h3>Denne side tilbyder:</h3>
<span class="OfferStyle">100% Indbetaling + 50 FreeSpins</span>
</div>
<div class="ClickMeBox">HENT DIN BOUNUS NU</div>
<div class="Box">INDBETALING ER NODVENDIGT</div>
</div>
</a>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</body>
</html>