首页 > 解决方案 > 转换宽度为 1920 像素的布局时优化容器和排版

问题描述

大家好,我想问一下我在将设计文件宽为 1920px 的布局转换为 html 时遇到了麻烦。如何在响应时优化容器和排版。我希望在调整大小时缩小字体大小和行高。谢谢

标签: htmljquerycssresponsive-design

解决方案


你好,你可以试试这个:

<!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>

推荐阅读