I want to expand the clickable part of the link_to method

Introduction

I used the link_to method to make page transitions, but I was dissatisfied with the fact that the only clickable part was the characters, so I investigated and implemented it.

Change to block element with CSS, padding

Give the link_to method a class name. When attaching class:" class name " Style the class name with display: block; in CSS. Furthermore, if you expand the range with padding, the clickable part will expand.

By the way, even if you margin, the part that can be clicked does not expand.

erb


<ul>
  <li class="menu-list">
    <%= link_to 'My page', hoge_path, class: "menu-name" %>
  </li>
  <li class="menu-list">
    <%= link_to 'calendar', hoge_path, class: "menu-name" %>
  </li>
</ul>

css


.menu-list {
  margin: 30px auto;
  border: black 3px solid;
  padding: 0px;
}
.menu-name {
  display: block; 
  padding: 30px;
}

display: block; and padding are the important parts.

Recommended Posts

I want to expand the clickable part of the link_to method
I want to output the day of the week
I want to var_dump the contents of the intent
I want to pass the argument of Annotation and the argument of the calling method to aspect
I want to call a method of another class
I want to know the answer of the rock-paper-scissors app
I want to display the name of the poster of the comment
I want to call the main method using reflection
[Rough commentary] I want to marry the pluck method
I want to be aware of the contents of variables!
I want to return the scroll position of UITableView!
How to use the link_to method
I want to change the log output settings of UtilLoggingJdbcLogger
I want to call a method and count the number
I tried to explain the method
I want to use the sanitize method other than View.
[Rails] I want to display the link destination of link_to in a separate tab
I want to narrow down the display of docker ps
[Ruby] I want to reverse the order of the hash table
I want to temporarily disable the swipe gesture of UIPageViewController
I want to understand the flow of Spring processing request parameters
The story of Collectors.groupingBy that I want to keep for posterity
[Rails] How to omit the display of the character string of the link_to method
I want to limit the input by narrowing the range of numbers
I tried to understand how the rails method "link_to" is defined
I want to control the default error message of Spring Boot
I want to change the value of Attribute in Selenium of Ruby
I wanted to add @VisibleForTesting to the method
I was addicted to the roll method
I want to know the Method of the Controller where the Exception was thrown in the ExceptionHandler of Spring Boot
A memo when you want to clear the time part of the calendar
I want to display the number of orders for today using datetime.
I want to know the JSP of the open portlet when developing Liferay
[Ruby] I want to extract only the value of the hash and only the key
I want to get the field name of the [Java] field. (Old tale tone)
I want you to use Enum # name () for the Key of SharedPreference
[Ruby] I want to do a method jump!
When you want to use the method outside
Output of how to use the slice method
I want to truncate after the decimal point
I want to get the value in Ruby
I want to get the value of Cell transparently regardless of CellType (Apache POI)
I want to control the start / stop of servers and databases with Alexa
I want to separate the handling of call results according to the API caller (call trigger)
I want to see the contents of Request without saying four or five
I want to recursively get the superclass and interface of a certain class
[Java] I want to calculate the difference from the date
I want to embed any TraceId in the log
I was addicted to the record of the associated model
I tried to summarize the state transition of docker
05. I tried to stub the source of Spring Boot
I want to judge the range using the monthly degree
I tried to reduce the capacity of Spring Boot
I want to dark mode with the SWT app
I am keenly aware of the convenience of graphql-code-generator, part 2
I want to simplify the log output on Android
I want to add a delete function to the comment function
Rspec: I want to test the post-execution state when I set a method on subject
[Ruby] I want to make a program that displays today's day of the week!
Rails The concept of view componentization of Rails that I want to convey to those who want to quit
[Must-see for beginners] I changed the display of the posting time to Japanese time [l method]