简体   繁体   English

如何在rails中的html.erb中增大行之间的间距?

[英]How to make the space between lines larger in html.erb in rails?

Here is the html.erb code we have to make the space between <li> elements larger. 这是html.erb代码,我们必须增大<li>元素之间的间距。

<table width="90%", style="font-size:20px;line-height:44px;">
  <tr>
    <td width="40%" valign="top">
      <ul>
        <li><%= link_to 'Expense', SUBURI + "/authentify/view_handler?index=1" %></li>
        <li><%= link_to 'Category', SUBURI + "/authentify/view_handler?index=1" %></li>
      </ul>
    </td>
  </tr>
</table>

The font size works. 字体大小有效。 However the line-height:44px is not working at all. 但是, line-height:44px根本不起作用。 How can I make the line-height work here in the html.erb? 如何在html.erb中使line-height起作用? Thanks. 谢谢。

You need to learn CSS and how it controls the look of your HTML files. 您需要学习CSS及其如何控制HTML文件的外观。 In this case what you are looking for is more padding. 在这种情况下,您要寻找的是更多填充。 You can set padding on the individual <li> (list item) elements like this: 您可以像这样在各个<li> (列表项)元素上设置填充:

<li style="padding-bottom: 10px"></li>

or, you can set that padding on ALL <li> elements through CSS: 或者,您可以通过CSS在所有<li>元素上设置该填充:

<style>
    li { padding-bottom: 10px; }
</style>

Even better - you can set a class name on your entire list, and have that define your padding. 更好的是-您可以在整个列表中设置一个类名,然后用它来定义填充。 This way you don't accidentally add padding to other <li> that you don't mean to: 这样,您就不会意外地向其他<li>添加填充,而这些填充并不是您想要的:

 <style>
    ul.add-padding li {padding-bottom: 10px; }
 </style>
 <!-- later on in the HTML -->
 <ul class="add-padding">
    <li>link 1</li>
    <li>link 2</li>
 </ul>

CSS 的CSS

Further to @lightswitch05 ' s answer, you need to appreciate the importance of including "unobtrusive" css in your app. 除了@lightswitch05的答案,您还需要了解在应用程序中包含“不干扰” css的重要性。 CSS is basically just a way to style elements on your page, allowing you to send CSS基本上只是一种样式页面上的元素的方式,允许您发送

CSS ( cascading style sheets ) are there to provide your app with styling, however, the best developers know that CSS is meant to live in external files (which Rails keeps in the asset pipeline ) CSS( cascading style sheets )可以为您的应用程序提供样式,但是,最好的开发人员知道CSS旨在驻留在外部文件中(Rails保留在asset pipeline


Inline 排队

You're currently doing this: 您当前正在执行此操作:

<table width="90%", style="font-size:20px;line-height:44px;">

BIG problem - you're styling individual elements in the page. 大问题-您正在样式页面中的各个元素。 Not only does this bloat the page, but it prevents extensibility 这不仅会使页面膨胀,而且会阻止扩展性


Pipeline 管道

As suggested, you're best doing this: 如建议的那样,您最好这样做:

<table width="90%" class="new_table">

This means you can then call the following file: 这意味着您可以随后调用以下文件:

#app/assets/stylesheets/application.css
.new_table {
     font-size:20px
     line-height:44px;
}
.new_table tr td ul {
   line-height: 44px;
}

I'd highly recommend you read up on how to integrate CSS with your app with the asset pipeline 我强烈建议您阅读如何通过资产管道将CSS与您的应用程序集成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM