简体   繁体   English

如何使用 bootstrap 4 处理图像上的响应文本

[英]How can i do responsive text that is over an image with bootstrap 4

I have an image that has content inside, i want the letters that are inside of the image to be responsive, when i resize the screen the letters should have the same proportions, but now they overlap each other when resizing screen, i need to do it only with the grid of bootstrap, cant be with media queries我有一个里面有内容的图像,我希望图像里面的字母是响应式的,当我调整屏幕大小时,字母应该具有相同的比例,但是现在在调整屏幕大小时它们相互重叠,我需要做它仅与引导程序网格,不能与媒体查询

 .banner{ position: relative; } .heading-annual{ position: absolute; top: 10%; color: whitesmoke; left: 7%; } .heading-medicine{ position: absolute; top: 25%; color: whitesmoke; left: 7%; } .heading-manchester{ position: absolute; top: 43%; color: whitesmoke; left: 7%; } .heading-date{ position: absolute; top: 55%; color: whitesmoke; left: 7%; }
 <div class="container-fluid px-0"> <div class="row"> <div class="col-md-12 col-lg-12 banner"> <img src="https://rcpmedicine.co.uk/wp-content/uploads/2018/11/new_banner_home.png" height="100%" width="100%" > </div> </div> </div> <h1 class="heading-annual">RCP annual conference</h1> <h1 class="heading-medicine">Medicine 2019</h1> <h4 class="heading-manchester">Manchester Central</h4> <h4 class="heading-date">25-26 April 2019</h4>

Is there any reason you must use img?有什么理由必须使用 img 吗? Could you not use background image instead?你不能用背景图片代替吗?

Try this.尝试这个。

 .banner { min-height: 500px; display: flex; align-items: center; background-image: url(https://rcpmedicine.co.uk/wp-content/uploads/2018/11/new_banner_home.png); background-size: cover; background-repeat: no-repeat; background-position: center; padding: 50px; color: white; }
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <div class="container-fluid banner"> <div class="row"> <div class="col-md-12 col-lg-12 "> <h1 class="heading-annual">RCP annual conference</h1> <h1 class="heading-medicine">Medicine 2019</h1> <h4 class="heading-manchester">Manchester Central</h4> <h4 class="heading-date">25-26 April 2019</h4> </div> </div> </div>

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

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