【发布时间】:2021-05-20 18:56:05
【问题描述】:
目前正在发生的事情: 当使用 Chrome 浏览器设备工具栏工具以不同的分辨率测试我的网站时,我注意到当我将设备屏幕缩小到“Mobile-s”320 像素时,我页面上的内容变得几乎无法阅读。这也导致图像非常小,更不用说分解到单个字母堆叠在一起的句子了。
我希望发生的事情:我希望卡片中的内容随着屏幕分辨率的降低而缩小,但也变得可读并且图像保持足够大以便被看到。
我在项目中使用的内容:
- html
- CSS
- Booststrap 5
这是我的博客部分的 html:
您可以看到我在最外层的 div 中使用了 container-fluid。
<h2 class="display-6 mb-5">My blog:</h2>
<div class="container-fluid">
<div class="row">
<div class="col-md-4 ">
<div class="card " >
<img src="img/1.jpg" class="card-img-top " alt="...">
<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>
这是我的图片部分的 html:
你可以看到我也在最外面的 div 中使用 container-fluid。
<h2 class="display-6">My projects:</h2>
<div class="container-fluid">
<div class="row gy-5"> <!--gy-5 will provide spacing between each image -->
<div class="col-md-6"><img src="img/1.jpg" alt="Portfolio image" class="img-fluid thumbnail">
</div>
<div class="col-md-6"><img src="img/1.jpg" alt="Portfolio image" class="img-fluid thumbnail">
</div>
<div class="col-md-6"><img src="img/1.jpg" alt="Portfolio image" class="img-fluid thumbnail">
</div>
<div class="col-md-6"><img src="img/1.jpg" alt="Portfolio image" class="img-fluid thumbnail">
</div>
<div class="col-md-6"><img src="img/1.jpg" alt="Portfolio image" class="img-fluid thumbnail">
</div>
<div class="col-md-6"><img src="img/1.jpg" alt="Portfolio image" class="img-fluid thumbnail">
</div>
</div>
</div>
这是我的 CSS 中包含的内容:
body, html{
height: 100%;
}
body{
font-weight: 200;
font-size: 1.5rem;
color: #444;
}
.intro-left{
background: url("../img/1.jpg");/*concrete background*/
position: fixed;
left: 0;
width: 33.3333%;
height: 100%;
color: white;
}
@media(max-width: 768px) { /*@media rule will add the code inside only if the max-width is 768px */
.intro-left{
height: 80vh;
margin-bottom: 0;
position: relative;
width: 100%;
}
}
.avatar{
width: 10rem;
height: 7em;
border-radius: 50%;
margin: 1rem;
}
.full-height {
height: 100%;
}
.quote{
float: right;
}
section{
margin: 5rem;
font-size: 1.2rem;
}
a{
color: #444;
text-decoration: none;
}
卡片目前在 320 像素上的显示效果
图像当前在 320 像素上的外观
卡片应该在 320 像素上的外观
图像应该在 320 像素上的显示效果
【问题讨论】:
标签: html css bootstrap-4 bootstrap-5