On a page with a web application made with Ruby on Rails, the characters in the table made with the Table tag were aligned. It looks bad as it is, so I investigated how to apply CSS so that it is vertically centered, so I will leave it as a memo for myself.
Files in / marketpurser / app / assets / stylesheets. If you add it to application.scss that exists by default, it will be applied to all views. Also, if you add it to the .scss file that corresponds to the name of the View, it will only apply to a specific View.
It seems that the same grammar as CSS is fine. This time, I want to apply it to the td tag in the table tag that has the table class, so I wrote it as follows.
/marketpurser/app/assets/stylesheetssample.scss
table.table td {
vertical-align:middle;
}
sample.html.erb
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Info</th>
</tr>
</thead>
<tbody id="myTable">
<tr>
<td>1</td>
<td>data1</td>
</td>
</tbody>
</table>
solved. In addition, instead of simply reloading the browser, the CSS was not reflected unless I accessed the modified View page again. (Primitive mistake)
That's my personal note.
Recommended Posts