html - 全角响应式两列布局图像和文本
问题描述
我正在寻找线索来设计像本页顶部这样的横幅:https ://www.gazteaukera.euskadi.eus/inicio/
我正在尝试自己,但没有得到我想要的(见下文)。我希望左侧的图像列和右侧的文本列完全对齐。我希望它具有响应性,以便在较小的屏幕中,左列将放置在右列的顶部(顶部和底部 div 之间没有空间)。
我在获得我想要的东西时遇到了一些问题。我希望有一个人可以帮助我 :)
代码:
.row {
background-color: blue;
padding: 0px;
/*I have added a background-color to help me solve the design issues, but this is sthg to be removed*/}
.column {
float: left;
width: 50%;
padding: 0px;
}
.row:after {
content: "";
display: table;
clear: both;
}
.title {
font-size: 24px;
color: #0FD955;
padding: 15px 15px 0px 15px;
font-weight: bold;}
.text {
font-size: 18px;
color: #0FD955;
padding: 0px 15px 15px 15px;
}
.imgw100 {
width: 100%;
}
@media screen and (max-width: 980px) {
.column { width: 100%; }
.right { width: 100%; }
.left { width: 100%; }
}
<div class="row">
<div class="column right">
<img class="imgw100" src="https://butterfly-conservation.org/sites/default/files/styles/masthead/public/2019-03/16548509661_3bdddd5179_o.jpg" />
</div>
<div class="column left" style="background-color: #022C11;">
<p class="title">Breaking news</p>
<p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
解决方案
将显示 css 添加到行作为较大设备的 flex 添加用于小屏幕 添加显示 css 作为行块
.row {
background-color: blue;
padding: 0px;
display: flex;
}
.title {
font-size: 24px;
color: #0fd955;
padding: 15px 15px 0px 15px;
font-weight: bold;
}
.text {
font-size: 18px;
color: #0fd955;
padding: 0px 15px 15px 15px;
}
.imgw100 {
width: 100%;
}
@media screen and (max-width: 480px) {
.row {
background-color: blue;
padding: 0px;
display: block;
}
}
推荐阅读
- echarts - echarts获取当前时间窗口
- azure - 如何指示 Azure 管道从 Azure 保管库读取存储帐户密钥,以便在发布代码期间配置诊断扩展?
- r - 如何使用 dplyr 在分组 tibble 中仅过滤特定组(满足特定条件)?
- php - TCPDF 中的德语字符 - PHP
- python-3.x - 使用python将SFTP文件从一台远程服务器(linux)传输到另一台远程服务器(linux)
- docker - 是否可以挂载 pip 库的安装位置,以便库在运行 Jupyterlab 的 docker 容器中持久存在?
- apache-spark - pyspark用空字符串替换重复的反斜杠字符
- node.js - 修复 Bootstrap 中文本的宽度
- javascript - 当某人有太多角色无法嵌入嵌入时,如何发送“无法显示的角色太多”消息?
- aws-lambda - 定义类似于请求模式的无服务器框架 Api Gateway 响应模式