简体   繁体   English

如何使用引导程序使我的横幅响应

[英]How to make my banner responsive using bootstrap

I am trying to make a banner which looks like this我正在尝试制作一个看起来像这样的横幅

In mobile it should be look like this在移动设备中它应该是这样的

I am using bootstrap in this project.我在这个项目中使用引导程序。 I am able to achieve this in web view but in mobile its not working well.我能够在 web 视图中实现这一点,但在移动设备中它不能很好地工作。

 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous"> <div style="background-color:#BBD4FD"> <div class="container"> <div class="row block"> <div class="row-md align-items-center pt-4" style="height: 100px;"> <h1 class="text-center" style="letter-spacing: .1rem; font-size: 4rem; color:#183C77">Know how DrinkPrime solves the problem</h1> </div> <div class="row"> <div class="col-md align-items-center one" style=" height: 400px; width: 100%;"> <div class="text-center">One of three columns</div> </div> <div class="col-md one" style="height: 400px; width: 100%;"> <div class="text-center">One of three columns</div> </div> <div class="col-md " style="height: 400px; width: 100%;"> <div class="text-center">One of three columns</div> </div> </div> </br> </div> </div> </div>

How to make this responsive and look like mobile view?如何使这种响应式并看起来像移动视图?

Since you are using the Grid system from Bootstrap, remove the inline css <style=" height: 400px; width: 100%;"> As you have re-defined the width so your bootstrap resizing would be over-ridden.由于您使用的是 Bootstrap 的网格系统,因此删除内联 css <style=" height: 400px; width: 100%;">因为您重新定义了宽度,因此您的引导程序调整大小将被覆盖。

We use bootstrap classes so that the css library takes care of the resizing for us.我们使用引导程序类,以便 css 库为我们处理调整大小。 You don't need to override.你不需要覆盖。

Take a look at responsive design here - https://getbootstrap.com/docs/4.1/layout/grid/在此处查看响应式设计 - https://getbootstrap.com/docs/4.1/layout/grid/

You have a few problems to solve.你有几个问题需要解决。

  1. Don't put widths on your layout library's elements.不要在布局库的元素上放置宽度。 That's just a violation of the whole idea of a layout library.这只是违反了布局库的整体理念。 Always assume that the library has a means of achieving your goal and look for it in the documentation.始终假设库有实现目标的方法,并在文档中查找。

  2. You have oddly nested rows.你有奇怪的嵌套行。 Be sure to close one before opening another.在打开另一个之前一定要关闭一个。

  3. You have an odd closing line break tag in there (which isn't actually a thing-- br tags are self-closing).你必须有一个奇怪的收线突破标签(这实际上不是一个件事- br标签是自闭)。 Don't use line breaks for layout.不要在布局中使用换行符。 Use margins or other structural mechanisms.使用边距或其他结构机制。

Fix those things and you're in good shape.解决这些问题,你的状态就很好。 Note that I've added the border-bottom class as a starting point for customization.请注意,我已经添加了border-bottom类作为自定义的起点。 Border docs边界文档

 .height-100 { min-height: 100px; } h1.styled { letter-spacing: .1rem; font-size: 2rem; color: #183C77; }
 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous"> <div style="background-color:#BBD4FD"> <div class="container"> <div class="row"> <div class="align-items-center pt-4"> <h1 class="text-center styled">Know how DrinkPrime solves the problem</h1> </div> </div> <div class="row"> <div class="col-md height-100 border-bottom align-items-center"> <div class="text-center">One of three columns</div> </div> <div class="col-md height-100 border-bottom"> <div class="text-center">One of three columns</div> </div> <div class="col-md height-100 border-bottom"> <div class="text-center">One of three columns</div> </div> </div> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM