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