在MVC3 CSS背景图片 [英] CSS background images in MVC3

查看:1470
本文介绍了在MVC3 CSS背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建我MVC3应用程序样式表。我不知道如何将背景图片格式:URL。

I am trying to create style sheet for my MVC3 app. I'm not sure how to format the background-image:url.

background-image:url('../../Content/images/gradient_tile_page_top.png');

background-image:url('~/Content/images/gradient_tile_page_top.png');

我都试过也不工作。 CSS似乎有点麻烦,用MVC。

I've tried both and neither work. Css seems to be a little trickier with MVC.

推荐答案

如果您遵循规范你的主页的布局将是这样的:

If you're following the "norm" your main page layout will have something like:

<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />

和您的其他资产(例如图像),要么直接在内容文件夹或在图片文件夹中的内容所在。

and your other assets (images for example) will either reside directly in the content folder or in an "images" folder under content.

因此​​,在你的例子:

Therefore, in your example:

background-image:url('../../Content/images/gradient_tile_page_top.png');

变为

background-image:url('images/gradient_tile_page_top.png');

这篇关于在MVC3 CSS背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆