2012-07-06 105 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;} 
    
  • 我希望按照上面的步骤,您可以添加图片或标志到您的导航栏