2012-07-06 36 views
1

我一直試圖在導航欄上放置圖像的圖像只顯示名稱。資產管道中的圖像位於名爲images的文件夾中,我正在使用bootstrap。我現在有這個在我的代碼:在導航欄中放置圖像僅顯示圖像名稱而不顯示圖像

`<%= link_to image_tag('WikiLogoFinal.jpg'), getting_started_path, id: "logo" %>` 

我的CSS如下:

#logo { 
float: left; 
margin-right: 10px; 
font-size: 1.7em; 
color: $niceBlandGreen; 
text-transform: uppercase; 
letter-spacing: -1px; 
padding-top: 9px; 
font-weight: bold; 
line-height: 1; 
&:hover { 
font-size: 1.75em; 
color: white; 
background: $shinyOrange; 
text-decoration: none; 
} 
} 

的圖像不是問題,因爲我已經使用了不同的一個。

+0

是那些回抽動在你的實際代碼? – RadBrad 2012-07-06 18:10:31

+0

沒有這些網站的格式 – mustaisa 2012-07-09 19:44:13

回答

1

根據你有什麼,你的代碼應該工作。請確保您的圖像位於

app/assets/images 

目錄中。另外,請檢查以確保您已啓用資產管道。轉到

config/application.rb 

,看看你是否有這樣一行:

# Enable the asset pipeline 
config.assets.enabled = true 
0

爲了增加標誌或圖片,爲您的導航欄。執行以下步驟來完成:

  1. 打開navbar.html.erb,通常這個文件的佈局文件夾下的謊言中的意見,然後查找導航欄,品牌類如

<a class="navbar-brand" href="/"><img class="img-responsive2" src ="https://www.google.com.mx/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"> BLOG</a>

  • 添加以下的類代碼下到您navbar.scss文件.navbar

    .img-responsive2 { 
    display: inline-block; 
    max-width: 20%; 
    height: auto;} 
    
  • 我希望按照上面的步驟,您可以添加圖片或標誌到您的導航欄