簡體   English   中英

背景圖片將不會加載圖片Ruby on Rails

[英]Background-image will not load image Ruby on Rails

我已經實現了這一點:在我的rails應用程序中設置了動畫標題 一切正常,但我想更改頁眉圖像,由於某些原因,它無法加載...我在另一頁上嘗試了相同的語法來加載圖像,並且在rails中可以正常工作。

我該如何進行這項工作?我想念什么?

我更改的CSS代碼

.header:before {
  content: "";
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  -webkit-backface-visibility: hidden;
  -webkit-transform: translateZ(0) scale(1.0, 1.0);
  transform: translateZ(0);
  background-image: asset-data-url("header_background.jpg");
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-position: top center;
  background-color: #1B2030;
  background-size: cover;
  -o-background-size: cover;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  animation: grow 60s linear 10ms infinite;
  transition: all 0.2s ease-in-out;
  z-index: -2;
}

Codepen中的代碼

.header:before{
  content:"";
  width:100%;
  height:100%;
  position:absolute;
  top:0;
  left:0;
  -webkit-backface-visibility: hidden;
  -webkit-transform: translateZ(0) scale(1.0, 1.0);
  transform: translateZ(0);
  background:#1B2030 url(https://unsplash.it/1999/999?image=1063) top center no-repeat;
  background-size:cover;
  background-attachment:fixed;
  animation: grow 60s  linear 10ms infinite;
  transition:all 0.2s ease-in-out;
  z-index:-2
}

好吧,我知道了! 我在腳本標簽的視圖中使用了CSS,這就是為什么它無法加載的原因...我猜asset-data-url僅在CSS文件中實現時才有效...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM