【发布时间】:2022-01-07 15:01:47
【问题描述】:
我在浏览器上放大容器的背景图像时遇到问题。图片是1200pxwide,我的容器也是1200pxwide。我将它设置为我的 .container 选择器的背景图像。当我在浏览器中加载它时,它只显示图像的一小部分,因为它已经被放大了。为什么会这样?
HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" rel="stylesheet" href="css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="style.css">
</head>
<body>
<main role="main">
<article role="article">
<section>
<header>
<div class="container">
</div>
</header>
</section>
</article>
</main>
</body>
</html>
CSS:
@font-face {
font-family: "Brandon Grotesque";
src: url("fonts/Brandon_Grotesque/Brandon_reg.otf")
format("opentype");
}
html, body {
padding:0;
margin: 0;
background-color:#222222;
}
body {
font-family:"Brandon Grotesque";
width: 1200px;
margin: 0 auto;
}
.container {
width: 1200px;
height:600px;
background-image:url("img/background.jpg");
text-align:center;
margin:auto;
padding:0;
}
我错过了什么吗?
【问题讨论】:
-
哦,这是另一部分。它在 Chrome 中正确加载,但在 Safari 中不正确!我应该事先对此进行测试.....有我需要为他们安装的 webkit 吗?再次感谢!
-
bootstrap.min.css 中有什么东西覆盖了你的 style.css?您可以编辑该引导 css 文件(可能不想)或在 style.css 中添加更多属性以覆盖它们。在 style.css 属性中使用 !important,如果这不起作用,请添加内联样式,
<div class="container" style="background-image: url(img/background.jpg)">我看到有人回答了您想要摆弄的一些 css 属性将/可能是什么。
标签: html css twitter-bootstrap-3