gpt4 book ai didi

css - 如何使用 Bootstrap 4 使带有图像文本和链接的响应式连续三列?

转载 作者:太空宇宙 更新时间:2023-11-04 06:35:46 24 4
gpt4 key购买 nike

我正在努力使用 Bootstrap 4 连续设置三个响应列。

.buttons {
border: 1px solid #e86225;
color: #e86225 !important;
padding: 10px 20px;
font-size: 14px;
}

.buttons:hover {
border: 1px solid #ffffff;
background-color: #e86225;
color: #ffffff !important;
transition: background-color 1s, border 1s, color 1s;
}

.container-custom {
padding-top: 80px;
padding-bottom: 80px;
}

.custom-link {
padding: 15px 0;
}

.container p {
margin: 25px 0;
max-width: 400px;
}

@media(max-width: 767px){

.container-custom {
padding-top: 50px;
padding-bottom: 50px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">


<div class="container">
<div class="row container-custom justify-content-center">
<h2>Blog</h2>
<div class='d-flex flex-wrap pt-5'>
<div class="col-sm-12 col-md-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSHBMzMRL0g3ELio_DdCRvdajdF812AQPP2AbmM_jYr_66CnwgS" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nibh sem, ultricies sit amet tellus ut, iaculis interdum ante. Quisque at nibh ac diam faucibus congue.
</p>
<div class="custom-link">
<a href="" class="buttons">Read more ></a>
</div>
</div>
<div class="col-sm-12 col-md-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQh3Afn3A1FKb24tpO6eAdqr8hCdnafjqwCNqgjdSAWK1igoWfk" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nibh sem, ultricies sit amet tellus ut, iaculis interdum ante. Quisque at nibh ac diam faucibus congue.
</p>
<div class="custom-link">
<a href="" class="buttons">Read more ></a>
</div>
</div>
<div class="col-sm-12 col-md-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQFsb6TxovKdTNx-8gdo1R01nZXxRRauett2KQ_ci76VgjK2hR7" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nibh sem, ultricies sit amet tellus ut, iaculis interdum ante. Quisque at nibh ac diam faucibus congue.
</p>
<div class="custom-link">
<a href="" class="buttons">Read more ></a>
</div>
</div>
</div>
</div>

问题是当媒体屏幕宽度小于 767px 时,它们会向左移动。我想在列的中间制作图像,文本的开头应该在 imaeg 的开头,文本的结尾在图像的结尾,按钮也应该在图像的开头,如下所示:

enter image description here

最佳答案

只需将 width:100% 添加到您的图像中,这样它们就会占据列上的所有空间

.buttons {
border: 1px solid #e86225;
color: #e86225 !important;
padding: 10px 20px;
font-size: 14px;
}

.buttons:hover {
border: 1px solid #ffffff;
background-color: #e86225;
color: #ffffff !important;
transition: background-color 1s, border 1s, color 1s;
}

.container-custom {
padding-top: 80px;
padding-bottom: 80px;
}

.custom-link {
padding: 15px 0;
}

.container p {
margin: 25px 0;
max-width: 400px;
}
img{
width:100%;
}
@media(max-width: 767px){

.container-custom {
padding-top: 50px;
padding-bottom: 50px;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">


<div class="container">
<div class="row container-custom justify-content-center">
<h2>Blog</h2>
<div class='d-flex flex-wrap pt-5'>
<div class="col-sm-12 col-md-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSHBMzMRL0g3ELio_DdCRvdajdF812AQPP2AbmM_jYr_66CnwgS" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nibh sem, ultricies sit amet tellus ut, iaculis interdum ante. Quisque at nibh ac diam faucibus congue.
</p>
<div class="custom-link">
<a href="" class="buttons">Read more ></a>
</div>
</div>
<div class="col-sm-12 col-md-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQh3Afn3A1FKb24tpO6eAdqr8hCdnafjqwCNqgjdSAWK1igoWfk" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nibh sem, ultricies sit amet tellus ut, iaculis interdum ante. Quisque at nibh ac diam faucibus congue.
</p>
<div class="custom-link">
<a href="" class="buttons">Read more ></a>
</div>
</div>
<div class="col-sm-12 col-md-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQFsb6TxovKdTNx-8gdo1R01nZXxRRauett2KQ_ci76VgjK2hR7" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nibh sem, ultricies sit amet tellus ut, iaculis interdum ante. Quisque at nibh ac diam faucibus congue.
</p>
<div class="custom-link">
<a href="" class="buttons">Read more ></a>
</div>
</div>
</div>
</div>

关于css - 如何使用 Bootstrap 4 使带有图像文本和链接的响应式连续三列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54243613/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com