我这里有一个图像
,我只想要一个特定的位置来显示什么。但我的不工作。我只希望双手能够查看而不裁剪原始图像
。提前致谢
预期结果
HTML
<div class="banner">
<h1>できる限り<br>
自然な形で育てた<br>
こだわりの野菜です。</h1>
<h4>生産者/川口太郎・川口久美子さん(安芸市)</h4>
</div>
CSS
.banner{
background: url(../img/img1.png);
background-size: 100%;
padding: 32% 0 5% 6%;
color: white;
letter-spacing: 0.1em;
border-radius: 1%;
}
最佳答案
background-size
和 background-position
CSS 属性的组合。不要忘记您可以使背景大小值大于 100%。我会把这个扔给它并从那里进行微调:
.banner{
background: url(../img/img1.png);
// background-size takes height and width but shorthand is one value used for both
background-size: 200%;
// background-position options include center, cover, and more: https://developer.mozilla.org/en-US/docs/Web/CSS/background-position
background-position: center center;
}
关于html - 背景图像显示图像的特定部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55133964/