Buttons surrounding the image are exhibiting varied responsiveness

This is my initial inquiry.

In the application I'm working on with rails and bootstrap, I've noticed that when the screen size changes to small, the elements around the image do not adjust properly like they do on a medium or large screen. Here are some screenshots for reference:

https://i.sstatic.net/x6uBD.jpg - Everything looks good in this size. https://i.sstatic.net/yr5Au.jpg - In Bootstrap small size, things look off.

I want the stars and buttons to be positioned below the picture and within its width. I assumed that by placing everything inside the same

<div class="col-sm-4 col-md-3">
, Bootstrap would handle responsiveness automatically.

I am not applying any custom styling to this page, so no additional CSS is required for this question.

For resizing images, I am using paperclip gem.

<div class="row">
<% @movies.each do |movie| %>
    <div class="col-sm-4 col-md-3">                    
        <div class="thumbnail">
            <% if user_signed_in? %>
                <div class="js-rating" movie_id="<%= movie.id %>" data-rate-value=6></div>
            <% end %>
            <br>
            <%= link_to (image_tag movie.image.url(:medium), class: 'image'), user_movie_path(movie.user, movie) %>
            <% if movie.user == current_user %>
                <br>
                <div class="image-buttons">
                    <%= link_to 'Edit', edit_user_movie_path(movie.user, movie), class: 'btn btn-primary' %>
                    <%= link_to "Remove", user_movie_path(movie.user, movie), method: :delete, data: { confirm: "You Sure?" }, class: 'btn btn-primary btn-remove-main' %>
                </div>
            <% end %>
        </div>
    </div>
<% end %>

Answer №1

In simple terms, your query can be summarized as "How can I ensure that my thumbnail div is only as wide as the image it contains?

You can follow a similar approach to the one explained in this post: Make wrapper take maximum width of child image?

.wrapper {
  border: 1px solid red;
  display: inline-table;
  margin-top: 1em;
  width: 1%;
  text-align: left;
}

.col {
  text-align: center;
}
<div class="col">
  <div class="wrapper">
    <div>&#8902; &#8902; &#8902; &#8902; &#8902;</div>
    <img src="http://www.fillmurray.com/284/196">
    <button>My Button</button> <button>My Other Button</button>
  </div>
</div>

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

What is the best way to include a scrollbar in a modal window?

Does anyone know how to add a scroll function to my modal in CSS? I have too many elements and would like to implement a scrollbar. You can see what it looks like here: https://i.sstatic.net/4Txrn.png Any suggestions on how to add the right scrollbar? If ...

Wait to display the page until all AngularJS directives have finished loading their HTML content

I've encountered an issue in my AngularJS application where I created directives that load external HTML templates from another URL. The problem is that when I navigate to the page, the binding works fine but the directive's HTML doesn't loa ...

Executing JavaScript code within ASP.NET Visual Basic

My current web application uses jQuery and JavaScript, but I want to add more features that are supported in ASP.net VB. However, I am unsure if the JavaScript can run after the VB code. Essentially, I would like the web app to follow this sequence: ...

How can you utilize CSS to automatically generate section numbers, specifically for multiple sections?

Is it possible to automatically generate section numbering in CSS only when there are multiple sections present? I discovered that using CSS, one can create automatic numbering for sections. body { counter-reset: section } h2 { counter-reset: sub-section ...

Utilizing CSS with flex to set the height to 100% of the

I've encountered an issue while constructing a page with the GWT framework where setting an element's height to 100% doesn't work. Consider the following structure: <div id="main"> <div id="1"> <d ...

The only functional button in the table is the one located on the top row

My MVC Application is encountering an issue with only the first item in the table working perfectly, while the rest are not calling the method. Despite my extensive research, I have been unable to resolve this issue. Below is the code on my view. Can someo ...

Converting HTML tables into R

I have a series of HTML files with static content containing tables. I need to extract a specific column (4th column) from each table. I am currently using R to extract the tables from the HTML, but it seems like the rows are being combined for that partic ...

Encountering an undefined variable error with Ruby on Rails 6 Bootstrap after restarting the server

I'm facing an issue in rails 6 where upon server restart, I encounter an Error: Undefined variable. Oddly enough, if I comment out the SCSS variables in my files, refresh the page, then un-comment them and refresh again, everything works as expected a ...

Allowing BeautifulSoup to bypass a portion of my html code or divide it

<!DOCTYPE html> <html class="client-nojs" dir="ltr" lang="en"> <body> <h2><span class="mw-headline" id="Danish">Danish</span></h2> <h3><span class="mw-headline" id="Noun">Noun</span><span clas ...

Suboptimal placement of second submenu in Navbar

This question is inspired by a discussion on Stack Overflow that you can read here. Everything seems to be working fine, except when the 2nd level item is not at the top. In the example provided, the item with the 2nd level menu is the first item. If you m ...

Load ajax asynchronously once the page has finished loading

I am exploring the world of AJAX with jQuery for the first time, and I am still relatively new to jQuery. Here is the code structure: $(document).ready(function(){ data_url = $('.lazy_content').attr("data-url"); data_id = $( ...

Is it possible for me to create two images with varying opacities using jQuery hover?

I am having an issue with the small rounded button on my effect. I want it to be fully opaque and still clickable, but currently it is taking on the opacity of the entire link. If I adjust the z-index, the button goes on top of the link but then the fancyb ...

Troubles with showcasing icons on a website

I need some help with a minor issue that I'm stuck on. I'm trying to display an information icon that, when clicked, opens a pdf. The strange thing is that the icon doesn't show up on the page even though it exists on the server. However, wh ...

Unique CSS styling technique

Is there a way to design a unique form similar to the one shown below using CSS? ...

Difficulty with Vue.js updating chart JS label names

I have been working with Vue JS and implementing a chart in my single page application. However, I am encountering difficulties updating the Legend and despite numerous attempts and searches, I am unable to get it to update. Any assistance in correcting my ...

Spacing between DIV elements in a horizontal direction appeared as white space

Struggling to create a simple vertical layout without any unwanted whitespace? Look no further! Every time I add content to one of the divs, it ends up creating unnecessary space between them. Take a look at this visual example: Let's dive into my H ...

Creating a web form with HTML and integrating it with jQuery AJAX

Looking to fetch data from the server through jQuery AJAX on an HTML form and store the response in a PHP string variable. Here is my current code snippet: <form method="post" name="myform" id="myform" action="https://domain.com/cgi-bin/cgi.exe"> &l ...

Is there a way to calculate the word frequency in my text using plain JavaScript?

Welcome to the text entry section: https://i.sstatic.net/VlBvt.png After clicking on the COUNT button, it will direct you to this page: https://i.sstatic.net/sqKWc.png I can see my entered text and word count displayed. Now I'm curious, how can I ...

Creating a web layout or template using HTML

Currently in the process of developing a website, my goal is to construct html templates that include placeholders for injecting pages/content, menus, and other elements. While I admire AngularJS for its flexibility in achieving this, I fear it may be too ...

Is it possible to trigger a JavaScript function without altering its existing value?

I am looking for a way to repeatedly call a JavaScript function without altering its previous values. The challenge I am facing is with an icon JSON object that contains 15 different icons. I am using a switch statement to execute the corresponding functio ...