我是 HTML/CSS 的新手,我正在尝试到目前为止所学的内容。
我设置了页眉,但我想在页眉中使用背景图片。无论我做什么,我都无法使标题中的图像按比例显示。它要么是平铺的,要么是太大以至于我看不到标题中的图像。
到目前为止,这是我的工作代码:
<style>
header {
text-align: center;
font-family: 'Permanent Marker', cursive;
color: #AA1166;
max-height: 500px;
background-image: url("http://i.imgur.com/8ClzWQ5.jpg");
background-repeat: no-repeat;
background-size: cover;
同样,我是新手,所以我可能正在尝试完成一些我还没有学习正确代码的事情。有人可以解释一下吗?
最佳答案
我想要标题中的背景图片
请检查下面的代码。
<style type="text/css">
header {
text-align: center;
font-family: 'Permanent Marker', cursive;
color: #AA1166;
background-image: url("http://i.imgur.com/b6y6Xvb.jpg");
background-repeat: no-repeat;
background-size: cover;
background-color: #666;
width:960px;
height: 200px;
margin: 0 auto;
}
关于html - 为什么我不能在标题中缩放此图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25839929/