css - 我如何使用 bootstrap 4 在图像上做响应式文本
问题描述
我有一个内部有内容的图像,我希望图像内部的字母能够响应,当我调整屏幕大小时,字母应该具有相同的比例,但是现在它们在调整屏幕大小时相互重叠,我需要做它仅与引导程序网格一起使用,不能与媒体查询一起使用
.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>
解决方案
有什么理由必须使用 img 吗?你不能用背景图片代替吗?
尝试这个。
.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>
推荐阅读
- autohotkey - 使用 ControlClick 和 WinTitle 的问题
- wordpress - wordpress 在将文本显示给浏览器之前替换文本
- cypress - 赛普拉斯:如果未找到来自“cy.route()”的请求,则测试失败
- javascript - 角反应形式日期设定值
- flutter - 在 Flutter 中,如何使用 WebView 制作简单的浏览器小部件?
- r - 将大型数据集从长转换为宽(450 多个值变量)
- rdf - Semantic Web - Turtle 和 JSON-LD 是一回事吗 - 一种保存 RDF 的方法
- python - Python math.log 函数数学域错误
- android - 使用数据绑定在片段活动中映射片段?
- c# - Opencvsharp4.windows 'OpenCvSharp.Mat' 的类型初始化程序抛出异常。创建安装文件后收到此错误