html - 用于在计算机和移动设备上查看的编码列
问题描述
一个愚蠢的简单问题,但我是 CSS 新手,对 HTML 很生疏。
我需要在以下代码中添加什么,以便在移动设备上查看时,两列从左/右布局变为顶部/底部布局?
<html>
<head>
<style>
{
box-sizing: border-box;
}
/* Set additional styling options for the columns*/
.column {
float: left;
width: 50%;
}
.row:after {
content: "";
display: table;
clear: both;
}
</style>
</head>
<body>
<div class="row">
<div class="column" style="background-color:#FFB695;">
<h2>Column 1</h2>
<p>Data..</p>
</div>
<div class="column" style="background-color:#96D1CD;">
<h2>Column 2</h2>
<p>Data..</p>
</div>
</div>
</body>
</html>
解决方案
使用媒体查询。
@media(max-width:480px){
.column {
width: 100%;
}
}
推荐阅读
- yarnpkg - AWS CodeBuild 不适用于 Yarn 工作区
- c# - REST API 在 C# 中不接受多个参数
- functional-programming - 方案将列表定义为局部变量
- python - 是否可以将变量作为 CSS 类传递给 Django html 模板?
- javascript - 错误类型错误:无法读取未定义的属性“val”
- java - 错误:仅引导加载程序类支持共享,因为已附加引导类路径
- xamarin - Xamarin:重新打开会导致“NU1202”错误?
- mysql - 在 MySQL 中查找组
- reactjs - 商店没有有效的减速器?
- javascript - 在类构造函数中 this.button = document.getElementById('button') / Uncaught TypeError: Cannot read property 'addEventListener' of undefined?