html - 转换宽度为 1920 像素的布局时优化容器和排版
问题描述
大家好,我想问一下我在将设计文件宽为 1920px 的布局转换为 html 时遇到了麻烦。如何在响应时优化容器和排版。我希望在调整大小时缩小字体大小和行高。谢谢
解决方案
你好,你可以试试这个:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.example {
padding: 20px;
color: white;
}
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
.example {font-size:0.8rem;line-height:28px}
}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
.example {font-size:0.9rem;line-height:28px}
}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
.example {font-size:0.95rem;line-height:28px}
}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
.example {font-size:1rem;line-height:28px}
}
/* Extra large devices (large laptops and desktops, 1920px and up) */
@media only screen and (min-width: 1920px) {
.example {font-size:1rem;line-height:28px}
}
</style>
</head>
<body>
<h2>Typical Media Query Breakpoints</h2>
<p class="example">Resize the browser window to see how the background color of this paragraph changes on different screen sizes.</p>
</body>
</html>
推荐阅读
- matlab - 如何根据 Matlab 中的列条目拆分矩阵?
- javascript - 如何在虚拟列表中保留 Svelte 组件的状态?
- r - 如何计算 R 中 Cox 回归效应大小的统计功效?
- c# - UWP Xamarin C# - WebView 返回导航返回页面已过期
- constructor - Fortran 派生类型的“初始”语句/自动构造函数
- vba - 无法使用 stackoverflow 中的 VBA 代码解析 json 字符串
- powershell - 如何根据另一个变量从数组中返回字符串值?
- javascript - 如何在javascript中动态检测语言
- ms-access - MS Access 2016 Dcount动态功能
- postgresql - 更改 Postgres 中的时间戳格式