I introduced Bootstrap to the Rails environment, and when I thought about cleaning it up, I suddenly stumbled and shared it.
It is never inherited by the element of the link_to method
index.html
<body>
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="">tweetApp</a></li>
</ul>
</nav>
Since the navbar-dark class is set, the text color should be white, but it is blue.
index.erb
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="">
<%= link_to('tweetApp',"/") %>
</a>
</li>
</ul>
</nav>
The generated link is popping out of the a tag ...
index.erb
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href=""></a>
<a href="/">tweetApp</a>
</li>
</ul>
</nav>
Format link_to (link text, path [, option, HTML attribute or event attribute])
class option class:" class name "
Reference Rails document-About view
index.erb
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<%= link_to("TweetApp","/",class: 'text-light')%>
</nav>
Recommended Posts