目前我正在运行一个 mvc 应用程序,其中一页我必须使用一个图像作为主题。我尝试用谷歌搜索很多东西,但没有一个主题对我有用。
我从互联网上得到一个例子,其中一张图片用作主题,如下所示:
.intro {
max-width:100%;
height:auto;
position:relative;
background: url(~/Content/Images/1.jpg) no-repeat bottom-center;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
<body>
<section id="intro" class="intro img-fluid img-responsive">
</section>
</body>
这在 html 页面上工作正常,但我在我的一个 View 中使用的相同,但它不起作用。
需要有人帮忙。
最佳答案
尝试改用背景图像。还要检查您是否有权访问图像并向 html 添加一些内容以使背景可见。
.intro {
max-width: 100%;
height: auto;
position: relative;
background-image: url(http://www.w3schools.com/cssref/paper.gif);
background-repeat: no-repeat;
background-position: bottom center;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
在你的 Html 正文中
<section id="intro" class="intro img-fluid img-responsive">
<article>
<div>Article1</div>
</article>
<article>
<div>Article2</div>
</article>
<article>
<div>Article3</div>
</article>
</section>
关于css - 在 mvc 中使用图像作为页面的主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38291299/