【发布时间】:2019-09-12 05:23:48
【问题描述】:
我正在关注 This Guide 并排放置图像。在 PC 等较大的显示器上看起来不错:
但在移动设备上我得到了这个: 这显然是不对的,但该网站确实提到添加此功能以支持移动设备:
@media screen and (max-width: 500px) {
.column {
width: 100%;
}
}
但是当我添加它时,它会改进它: 但不能解决问题,我需要图像在移动设备上从上到下而不是左右,如Demo On The Site 所示。我该如何解决这个问题?
这是我的 HTML 脚本(这是一个测试,所以我理解它是最基本的):
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="description" content="Ultra Gamer Text">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ultra Gamer test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<div class="row">
<div class="column">
<a href="https://example.com" target="_blank">
<img src="./img/Testimage.png" alt="https://example.com" target="_blank">
</a>
<div class="textLink">
<h3><a href="https://example.com" target="_blank">Test</a></h3>
</div>
</div>
<div class="column">
<a href="https://example.com" target="_blank">
<img src="./img/Placeholder.png" alt="https://example.com" style="width:300px;height:300px;" target="_blank">
</a>
<div class="textLink">
<h3><a href="https://example.com" target="_blank">Test</a></h3>
<div class="column">
<a href="https://example.com" target="_blank">
<img src="./img/Placeholder.png" alt="https://example.com" style="width:300px;height:300px;" target="_blank">
</a>
<footer>
</footer>
</body>
</html>
这是我的图片 CSS 代码:
a
{
/* Removes underlines from links */
text-decoration: none;
color: black;
}
/* When mouse is hovering over text */
a:hover
{
color: rgb(85, 85, 85);
text-decoration:none;
cursor:pointer;
}
/* When mouse is hovering over an image */
img:hover
{
filter: brightness(0.8);
}
body
{
font: 15px/1.5 Arial, Helvetica,sans-serif;
background-color: #f0f0f0;
padding: 0;
margin: 0;
}
/* Three image containers (use 25% for four, and 50% for two, etc) */
.column {
float: left;
width: 33.33%;
padding: 5px;
text-align: center;
width:90px
}
/* Clear floats after image containers */
.row::after
{
content: "";
clear: both;
display: table;
text-align: center;
}
.row
{
display: flex;
}
.column
{
flex: 33.33%;
padding: 5px;
}
.textLink
{
color: black;
}
@media screen and (max-width: 500px) {
.column {
float:inherit;
width: 100%;
}
}
footer
{
text-align: center;
padding: 12px;
}
【问题讨论】:
-
请在此处添加您的代码以便更好地理解屏幕截图。
-
请向我们展示您的代码,以便我们检查出了什么问题。谢谢
-
不要低估minimal reproducible example的力量
-
分享你的html
标签: html css mobile-website