18910140161

HTML-图像未填满整个DIV-堆栈溢出

顺晟科技

2022-10-18 12:09:57

142

我有一个迪夫。在它里面,我有一个图像。图像的尺寸为540*420。我想让图像完全填满容器DIV,但这并没有发生。在图像的左边和右边是我想要删除的空白(在图像中用粉红色表示)。我的图片截图是:-

enter image description here

我的HTML:

<代码><;DIV类=";col-MD-6 col-sm-6";style=";background-color:粉红色;高度:270px;位置:相对;背景大小:封面;";>;<;IMG SRC=";images/about.JPG";style=";Max-width:100%;最大高度:100%;适合对象:包含;";/>;<;DIV style=";位置:绝对;最高:19%;左:13%;宽度:80%;";>;<;p style=";font-size:1.4em;颜色:#FFF;保证金:0;行高:1.7em;字体粗细:300;文本转换:大写;";>;苹果支付(Apple Pay)与拥有竞争产品的MCX集团发生冲突。<;/p>;<;/DIV>;<;/DIV>;

请帮助.


顺晟科技:

您正在使用类<div class="col-md-6 col-sm-6" style="background-color: pink; height: 270px; position: relative; background-size: cover;"> <img src="images/about.jpg" style="max-width: 100%; max-height: 100%; object-fit: contain;" /> <div style="position: absolute; top: 19%; left: 13%; width: 80%;"> <p style="font-size: 1.4em; color: #fff; margin: 0; line-height: 1.7em; font-weight: 300; text-transform: uppercase;"> apple pay runs afoul of mcx, a group with a rival product. </p> </div> </div> col-md-6。这些类包含15px左右填充规则:

col-sm-6

padding-right: 15px; padding-left: 15px; width: 100%height: 100%用于object-fit: cover来覆盖img规则即可。

<代码><;link rel=“ stylesheet ” href=“ UNK1@4.5.3/dist/CSS/bootstrap.min.CSS ” integrity=“ sha384-tx8t27ecre3e/ihu7zmqxvncday5uikz4rekgixemed4m0jlfidpvg6uqki2xxr2 ” crossorigin=“ anonymous ”>;<;DIV Class=“ col-MD-6 col-sm-6 ” style=" background-color:粉红色;高度:270px;位置:相对;背景大小:封面;填充:0;>;<;IMG SRC=“ https://www.imgonline.com.ua/examples/bee-on-daisy.jpg ” style="宽度:100%;高度:100%;对象匹配:封面;/>;<;DIV style=position:absolute;最高:19%;左:13%;宽度:80%;>;<;p style=font-size:1.4em;颜色:#FFF;保证金:0;行高:1.7em;字体粗细:300;文本转换:大写;>;苹果支付(Apple Pay)与拥有竞争产品的MCX集团发生冲突。<;/p>;<;/DIV>;<;/DIV>;

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航