[英]How do I align this text in bootstrap? [Responsive]
I'm trying to get this text to be aligned next to the image here.我正在尝试使此文本与此处的图像对齐。 (see picture) I am having problems with making it responsive and even just getting it there in the first place.
(见图)我在使其响应时遇到问题,甚至一开始就将其放在那里。
aside .box { position: relative; } aside .card { position: absolute; top: 0; transform: translateY(-100px); left: 0; right: 0; }
<header> <div class="jumbotron"> <p class="col-md-6 offset-md-6">Project Name</p> </div> </header> <div class="row"> <aside class="col-4"> <div class="box"> <div class="card"> <img class="card-img-top" src="https://picsum.photos/600/200" alt="Card image cap" /> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text"> Some quick example text to build on the card title and make up the bulk of the card's content. </p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div> </div> </aside>
Does this code work for you?这些代码在你那正常吗?
Edited: based upon your request to make it more responsive in smaller devices.编辑:根据您的要求,使其在较小的设备中更具响应性。
<header>
<div class="container-fluid">
<div class="row">
<div class="jumbotron col-12">
<p class="project__name position-relative col-md-4 col-lg-6 offset-md-4 offset-sm-0">Project Name</p>
</div>
</div>
<div class="row">
<aside class="col-12 col-md-4">
<div class="box">
<div class="card">
<img class="card-img-top" src="https://picsum.photos/600/200" alt="Card image cap" />
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">
Some quick example text to build on the card title and make up the bulk of the card's content.
</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
</aside>
</div>
</div>
</header>
CSS: changes that I would personally do. CSS:我个人会做的更改。
@media (min-width:768px) {
aside .card {
position: absolute;
top: 0;
transform: translateY(-100px);
left: 0;
right: 0;
}
.project__name {
top: 3rem;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.