html - Bootstrap4:“col-12”在手机屏幕上还是太宽,怎么换行?
问题描述
我将 Bootstrap4 用于网格系统。我正在使用col-12
手机屏幕和col-md-6
笔记本电脑屏幕。当我在手机上查看我的网站时,第一张图片太大,而且文字不换行但延伸到侧面。如何使用 bootstrap4 网格系统使我的内容适合移动屏幕?以下是我当前的代码:
.album {
margin-bottom: 100px;
}
.album img {
width: 800px;
}
.container {
width: 800px;
}
.content {
padding: 2px;
width: 100%;
}
.blogWriting {
margin-bottom: 80px;
padding: 15px 35px;
font-size: 13px;
}
.dateWriting {
text-align: right;
font-size: 13px;
padding: 15px 35px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="album container">
<div class="row justify-content-center">
<div class="col-12 col-md-auto">
<img src="https://via.placeholder.com/150" alt="d">
</div>
</div>
<div class="row justify-content-center">
<div class="col-12 col-md-6 content">
<div class="blogWriting">
<p><b>Crown Heights</b> is simply dummy text of
the printing and typesetting industry.
Lorem Ipsum has been the industry's standard
dummy text ever since the 1500s,
when an unknown printer took a galley
of type and scrambled it to make a type
specimen book. It has survived not only
five centuries, but also the leap into
electronic typesetting, remaining
essentially unchanged.
</p>
<p><b>Bushwick</b> is simply dummy text of
the printing and typesetting industry.
Lorem Ipsum has been the industry's standard
dummy text ever since the 1500s,
when an unknown printer took a galley
of type and scrambled it to make a type
specimen book. It has survived not only
five centuries, but also the leap into
electronic typesetting, remaining
essentially unchanged.
</p>
</div>
</div>
<div class="col-12 col-md-6 content">
<div class="dateWriting">
<p>October 28th, 2020 <br>
By Name</p>
</div>
</div>
</div>
</div>
解决方案
图像和容器的大小定义为 800 像素,因此它将始终为 800 像素,对移动设备使用媒体查询或使用宽度:100% 作为 img 样式
.album {
margin-bottom: 100px;
}
.album img {
width: 100%;
}
.container {
width: 100%;
}
或试试这个
.album {
margin-bottom: 100px;
}
.album img {
width: 800px;
}
.container {
width: 800px;
}
@media(max-width: 767px){
.album img {
width: 100%;
}
.container {
width: 100%;
}
}
推荐阅读
- angular - 我们如何从离子选择的下拉菜单中删除插入符号。我不想显示任何图标。应该只显示文本
- vb.net - 为什么用 vb.net 创建的相同像素大小的 .bmp 文件具有不同的文件大小?
- javascript - 获取 ngFor 根据名称重复数据
- ruby-on-rails - 有人有将 Avatara AvaTax 集成到条纹发票中的经验吗?
- uinavigationcontroller - 水平流iOS 12中的TabbarCoordinator中未调用后退按钮
- pandas - Pandas - 提取字典中的元素
- python-3.x - BERT 二进制文本分类每次运行都会得到不同的结果
- android - 如何使用维基百科 API 从维基百科页面的特定部分提取数据?
- java - 从“@WebFluxTest”迁移到“@SpringBootTest”后,集成测试中的连接被拒绝
- javascript - 在 Angular 组件中显示嵌套的 Json