Troubleshooting problem with button alignment in Rails 5 and Bootstrap 4

For the code repository, visit https://github.com/tenzan/shop/tree/bootstrap

In the displayed image (show action), the Edit and Delete buttons are currently positioned vertically. I want to change their position as shown in the second image below, aligning both buttons with the word Test.

The code snippet from show.html.erb:

<header>
  <h1><%= @category.name %></h1>

  <ul class="actions">
    <li><%= link_to "Edit Category", edit_category_path(@category),
            class: "edit"  %></li>

    <li><%= link_to "Delete Category", category_path(@category),
       method: :delete,
       data: { confirm: "Are you sure you want to delete this category?" },
        class: "delete" %></li>
  </ul>
</header>

The stylesheet for these two buttons is as follows (Check a.edit and a.delete sections):

ul.actions {
  @extend .list-unstyled;
  @extend .list-inline;
  position: absolute;
  bottom: -2px;
  right: 2px;
  max-width: 45%;
  text-align: right;
}
a.new, a.edit, a.delete {
  @extend .btn;
  &:before {
    font-family: "FontAwesome";
    padding-right: 0.5em;
  }
}
a.new {
  @extend .btn-success;
  &:before {
    @extend .fa-plus;
  }
}
a.edit {
  @extend .btn-primary;
  &:before {
    @extend .fa-pencil;
  }
}
a.delete {
  @extend .btn-danger;
  &:before {
    @extend .fa-trash;
  }
}

This is the current appearance https://i.sstatic.net/XvJHY.png

This is the desired layout https://i.sstatic.net/86PVQ.png

Answer №1

1. Simplifying it:

If you want to display "Edit Category" and "Delete Category" in a single line, you can achieve this by eliminating the <li> tags. The code would look like this:

<div class="row">
  <%= link_to "Edit Category", edit_category_path(@category),
            class: "edit"  %> 
  ...
</ul>

2. Utilizing CSS:

In case you are unable to remove the <li> tags, you can still style the elements using CSS:

ul { list-style: none; }    /* Removes list bullets */
ul li { display: inline; }  /* Changes display of <li> elements to inline */

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporating JavaScript: Demonstrating content on button click based on pattern matching

I want to display content in a div when the user clicks on a button. There are three buttons: test connection src, test connection dest, and next. When I click on the test connection src button and there is no input, it should display a message. However, ...

I'm having trouble viewing my navigation bar, even though everything seems to be correct

I'm facing an issue where the navigation bar is not visible even though everything seems to be correct. I have checked and double-checked but still can't figure out what's wrong. It's becoming quite frustrating and I'm at a loss fo ...

Utilizing jQuery for displaying or hiding list elements

To view all the code, click on this link: http://jsfiddle.net/yrgK8/ A section titled "news" is included in the code snippet below: <ul id="news"> <li><p>asfdsadfdsafdsafdsafdsafdsafdsafdsa</p></li> <li>&l ...

Using jQuery to apply a CSS class to a chosen radio button

How can I dynamically add a CSS class to a radio button based on its selection? $("input[type=radio][name=align]").on('change', function() { var radVal = $("input[type=radio][name=align]").val(); if (radVal == 'center') { $(" ...

Creating a navbar dropdown that is clickable on mobile devices and opens on hover on desktop is a simple way to improve

Utilizing Bootstrap 5 for my website creation, I am facing an issue with the navbar dropdown functionality. On mobile devices, the dropdown opens upon clicking but fails to close when clicked again. Meanwhile, on desktops, hovering over the dropdown works ...

The issue of the flex: 1 view not expanding to its full height persists, along with the KeyboardAvoidingView functioning unre

My concern lies with a ScrollView that is not occupying the full remaining height, as shown here. The red-bordered view should extend all the way down, but it fails to adjust properly when the keyboard is visible like in the case of selecting the 5th item ...

Steer clear of altering line spacing in CSS

Here is the HTML structure that I am working with: <div id="id1"> <h1>my name </h1><h3><a href="mailto:myemail_id"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff92869a929e9693969bbf878685d19 ...

Is there a way to customize the default Bootstrap accordion button?

Looking for assistance on how to customize the default collapse button for Bootstrap 4 or 5 accordion using fontawesome icons. Can anyone help with this? Thanks in advance! Here is an example of an accordion: <div class="accordion" id="a ...

Changes in an image element's transition can result in either resizing or shifting positions

When I apply an opacity transition to an img element as shown here, I notice that the size of the image changes or it appears to move at the start and end of the transition. Below is a simple CSS code for styling: img{ height:165px; width:165px; ...

Top method for utilizing jQuery to locate, sift through, and implement CSS classes

Let's consider the following scenario: <span class="foo">7</span> <span class="foo">2</span> <span class="foo">9</span> We want to assign a CSS class of 'highest' to 'span.foo' with value great ...

Having trouble getting the edits in my SCSS file to reflect in the HTML

After downloading a theme, I attempted to edit the background of the "navbar_fixed" in the <header class="main_menu_area navbar_fixed"> .scss code for custom CSS. However, despite my efforts, the changes made in the .scss file do not reflect in the H ...

Is it recommended to employ @media print for a webpage dedicated exclusively to printing purposes?

Imagine a scenario where I have a specific page featuring a print button. Clicking on this button redirects me to a separate page with the same content, optimized for printing purposes. Instead of using @media print directly on the original page due to n ...

The jQuery CSS menu is having trouble highlighting the active link

Can you help me figure out what's wrong with this code and how I can fix it? I'm working on a CSS menu (horizontal) where I want the background and font to change when an item is selected. I found some jQuery code from another post that should m ...

Presenting titles and buttons within a Bootstrap modal window

I have implemented a modal using vue-bootstrap. The code for the modal is as follows: <template id="child"> <b-modal v-model="showModal" size="lg"> <template v-slot:modal-header> <h4 class="modal-title"> ...

Complicated alignment of third-party (Facebook "like" and Google +1) buttons with CSS styling

What is the optimal arrangement for positioning the Google+1 and Facebook Like buttons to ensure they line up neatly? Currently, the initial element in my body is this heading, which appears at the top of all pages (lightly modified after logging in): &l ...

Preserve the collapsed state during postback in ASP.NET

I've implemented two collapsible forms that can switch between each other using a button control. <div> <button type="button" data-toggle="collapse" data-target=".multi-collapse" ...

Do mobile CSS/HTML have distinct rules to follow?

I am having trouble displaying a background image in CSS. Additionally, I am unable to set a background color for a div. #mlogo { background-image: url(/mobileimages/2015LOGOFB.jpg); background-size: 100%; background-position: top; backgro ...

"Disabling Click Event on Sidebar Menu in Angular: A Step-by-Step Guide

I am working on an Angular project with a sidebar that I want to modify in order to disable click events on the menu items. My goal is to guide users through a specific flow without allowing them to navigate freely. However, simply disabling the [routerLin ...

Collapsed navbars in Bootstrap 5 fail to display properly in a two-column format

Looking to create a responsive Bootstrap 5 navbar that collapses at the md breakpoint and displays navlinks in two columns upon collapse. Currently facing an issue where the navbar remains expanded and the toggle button fails to work after hitting the br ...

Create a button that matches the dimensions of the background image

I am working with a form that includes a submit button featuring a background image. <button type="button" class="button" alt="Send" onclick="validate_form_newsletter_wide( form )"></button> Everything works well when I define the dimensions ...