html - 调整图像

标签 html css image centering

我需要将我的图片调整为导航栏,但我似乎无法调整图片大小或“移动”图片。怎么了? (图像需要居中,并调整大小以适合导航栏宽度)

.forsidebillede {
width: 1000px;
height: 100px;
display: block;
    margin-left: auto;
    margin-right: auto
}
<section class="forsidebillede">
<img src="https://a2ua.com/grey/grey-002.jpg" alt="smoothies"/>
</section>

最佳答案

这里没有实际引用图像的代码。

下面会这样做。

.forsidebillede {
width: 1000px;
height: 100px;
display: block;
    margin-left: auto;
    margin-right: auto
}

.forsidebillede > img {
    width:100%;
    height:100%; /* Only if you want the height to be filled also */
    display:block; /* To remove any extra spacing */
}
<section class="forsidebillede">
<img src="smoothie.jpg" alt="smoothies"/>
</section>

关于html - 调整图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39765429/

相关文章:

php - 无法使用 PHP 在 MySQL 数据库中插入多个图像

javascript - 如何调整字体大小和重排文本以适应带有 html 标签的父 div 的宽度和高度

c++ - 在 GTK+-2.2 中显示 RGB 图像

html - 表响应类中的 Bootstrap datetimepicker 问题

HTML 表格根据条件更改文本颜色

javascript - CSS - 将较长的 Div 调整为较短的 Div

css - 在动画容器的子元素上忽略 z-index

jquery - 如何从 Bootstrap 中删除 css 背景颜色?

android - 在android中相互叠加绘制图像

javascript - 如何禁用或启用页面上图像的所有onClick