html - 如何在 ruby​​ on rails 中 float 我的图像标签?

标签 html css ruby-on-rails

我想将 logo.png float 到左侧,但它不起作用。这是我的 Rails 代码:

<!DOCTYPE html>
<html>
<head>
  <title>Pragprog Books Online Store</title>
  <%= stylesheet_link_tag   "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag    "application", "data-turbolinks-track"  => true %>
  <%= csrf_meta_tags %>
  </head>
  <body class="<%= controller.controller_name %>">
    <div id="banner">
        <%= image_tag ("logo.png") %>         <----------- can't move this thing!
        <%= @page_title || "Pragmatic Bookshelf"%>
    </div>
    <div id ="columns">
        <div id="side">
            <ul>
                <li><a href="http://www......">Home</a></li>
                <li><a href="http://www......">Questions</a></li>
                <li><a href="http://www......">News</a></li>
                <li><a href="http://www......">Contact</a></li>
            </ul>
        </div>
        <div id="main">
            <%= yield %>
        </div>
    </div>
  </body>
</html>

这是 CSS:

#banner {
    background: #9c9;
    padding: 10px;
    border-bottom: 2px solid;
    font: small-caps 40px/40px "Times New Roman", serif;
    color: #282;
    text-align:  center;
    img {
        float: left;
    }
}

我正在研究代码,但我似乎根本无法操纵图像。环顾四周寻找遗漏之类的东西,但找不到任何东西。我错过了什么?感谢您的帮助!

最佳答案

#banner {
background: #9c9;
padding: 10px;
border-bottom: 2px solid;
font: small-caps 40px/40px "Times New Roman", serif;
color: #282;
text-align:  center;
}
#banner img {
    float: left;
}
#banner h1 {
    text-align:center
}

当然这只是一个近似值,您需要进行调整,但请查看 this fiddle查看它是如何完成的并根据需要进行更改

关于html - 如何在 ruby​​ on rails 中 float 我的图像标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25336728/

相关文章:

javascript - 将焦点从输入元素更改为动态内容占位符 div

javascript - Polymer -> 类似于绑定(bind)中的 WPF/SL DataContext 的概念

html - QDomDocument 按类获取元素

javascript - 单击按钮时如何显示div?

html - 根据特定类的 sibling 调整 div 的大小

ruby-on-rails - 在unix中卸载手动编译的包

ruby-on-rails - Carrierwave PNG 到 JPG 转换器。如何避免黑色背景?

jquery - HAML- Jasmine 灯饰

html - 样式化 JSF ICEFaces ace :dialog

html - 如何在这 3 个水平元素之间留出空间