gpt4 book ai didi

html - 如何使图像响应并自动缩小高度

转载 作者:行者123 更新时间:2023-11-27 23:45:02 25 4
gpt4 key购买 nike

我有两个不相等的响应列,右边较小的是文本,左边较大的是图像。当我调整浏览器窗口的大小时以查看列如何适合页面时,它工作正常,直到达到最大宽度 700px 并且列相互堆叠。底部的列很好,但是顶部的(图像)不显示完整图像,只显示沿着页面宽度的一小条。我怎样才能让它自动调整高度以显示完整图像?

我曾尝试将左侧列的高度设置为自动,但这没有用,它继续只显示一个小 strip 。

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

非常感谢任何帮助:)

最佳答案

img{
max-width:100%;
height:auto;
display:none;
}
.left {
width: 60%;
background:url("http://i.imgur.com/k5gf0zz.jpg") no-repeat center;
background-size:cover;
}


.right {
width: 40%;
padding: 10px 0px;
}
.row{
display:flex;
flex-wrap:wrap;
}

@media screen and (max-width: 700px) {
.column {
width: 100%;
}
img{
display:block;
}
.left {
background:none;

}

}
<div class="row">
<div class="column left";>
<img src="http://i.imgur.com/k5gf0zz.jpg">

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

尝试将 img 添加到您的 html 中,为小屏幕添加 max-width:100%height:auto,为大屏幕添加带有 background 的 div屏幕!

关于html - 如何使图像响应并自动缩小高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56852713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com