html – 为什么我的图像宽度不是从父div宽度继承的

伙计我有这样的div:
<div id="image-container">
 <img id="image" src="#" > //with an image inside
</div>

并以这种方式设计:

#image-container {
    width: 750px;
    height: 360px !important;
    text-align: center;
}

但是当我加载页面并检查图像上的元素以了解其尺寸时,这就是它所说的:

element.style {
    height: 600px;
    width: 600px;
}

为什么图像不继承div的宽度?由于某种原因,我不能手动设置所需的图像宽度,所以我不能这样做:

#image {
 width : 330px; //manually putting width
 height: 303px; //same same which i cannot do this for some reason
}

知道为什么或如何解决这个问题?

我都尝试过以下解决方案:

这是我从inspect元素得到的:

#image {
    height: inherit; // crossed-out
    width: inherit; // crossed-out
}

有些东西会覆盖我的图像尺寸.

解决方法

试试这个 FIDDLE
#image-container {
    width: 750px;
    height: 360px !important;
    text-align: center;
    overflow: hidden;
}

#image-container img{ 
    width: inherit;
}

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些