【发布时间】:2019-07-03 00:45:19
【问题描述】:
我有两个不相等的响应列,右侧较小的是文本,左侧较大的是图像。当我调整浏览器窗口的大小以查看列如何适合页面时,它可以正常工作,直到达到最大宽度 700px 并且列堆叠到彼此上。底栏很好,但最上面的(图像)没有显示完整的图像,只有一个沿着页面宽度的小条。如何让它自动调整高度以显示完整图像?
我尝试将左列的高度设置为自动,但没有成功,它继续只显示一个小条。
.column {
float: left;
padding: 10px;
height: 300px;
}
.left {
width: 60%;
background-image: url('http://i.imgur.com/k5gf0zz.jpg');
background-size: cover;
background-position: center;
}
.right {
width: 40%;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 700px) {
.column {
width: 100%;
}
}
<body>
<div class="row">
<div class="column left";>
</div>
<div class="column right" style="background-color:#FDE4EC;">
<center> <p><font size="8">We Provide Quality Skin Care</font></p>
<p style = "font-family: Verdana, Geneva, sans-serif">Let us help you feel beautiful!</p>
<br>
<button class="button2"><b>BOOK NOW</b></button> </center>
</div>
</div>
</body>
任何帮助将不胜感激:)
【问题讨论】:
-
欢迎来到stackoverflow!为了让人们更容易理解您的问题,您能否提供一个更完整的示例,包括 HTML?理想情况下作为一个 sn-p。
-
完成,我添加了 html
-
这似乎受到列高的限制,固定为 300px
-
请注意,
<center>和<font>元素已经过时多年,不应再使用。 html.spec.whatwg.org/dev/obsolete.html#obsolete -
如果没有将列高固定为 300 像素,图像在它们甚至相互堆叠之前就是一条细条
标签: html css image responsive