我正在使用 CodeSleeve 的 asset-pipeline在我的 Laravel 元素(PHP 框架)上管理我的样式表。 application.css
文件下载好了,但是允许图片和字体使用的方法是什么?
我的 application.css 文件:
@font-face {
font-family: 'mrsMonster';
src: url('/fonts/mrsMonster/mrsmonster-webfont.eot');
src: url('/fonts/mrsMonster/mrsmonster-webfont.eot?#iefix') format('embedded-opentype'),
url('/fonts/mrsMonster/mrsmonster-webfont.woff') format('woff'),
url('/fonts/mrsMonster/mrsmonster-webfont.ttf') format('truetype'),
url('/fonts/mrsMonster/mrsmonster-webfont.svg#mrs._monsterregular') format('svg');
font-weight: normal;
font-style: normal;
}
#h-navbar {
font-family: mrsMonster;
background: url('/images/banniere.png') no-repeat;
}
最佳答案
解决办法是把fonts文件夹放到stylesheet目录下,然后写:
@font-face{
font-family: Airplanes;
src: url('fonts/airplanes/airplanes_in_the_night_sky-webfont.eot');
src: url('fonts/airplanes/airplanes_in_the_night_sky-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/airplanes/airplanes_in_the_night_sky-webfont.woff') format('woff'),
url('fonts/airplanes/airplanes_in_the_night_sky-webfont.ttf') format('truetype'),
url('fonts/airplanes/airplanes_in_the_night_sky-webfont.svg#airplanes_in_the_night_skyRg') format('svg');
font-weight: normal;
font-style: normal;
}
images文件夹可以和stylesheet文件夹在同一层,然后你应该这样写:
background: url('myImage.png');
关于css - 如何在 Assets 管道插件中使用字体和背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21970093/