Discrepancy in size upon initial page loading

I am utilizing Bootstrap features on my website to assist with my CSS. However, I have encountered a peculiar issue upon the initial page load where some elements are positioned incorrectly, but a simple page reload fixes it. Any suggestions on how to resolve this?

See below for reference images.

HTML:

<div class="media post-react">
  <%= link_to post do %>
    <div class="media-left hidden-sm hidden-xs">
      <%= image_tag("#{post.thumbnail_link}", :width => 320, :height => 180, class: "news-object") %>
    </div>

    <div class="media-body">
      <div id="media-heading">
        <h2 class="media-title align-left"><%= post.title %></h2>
        <p class="blog-index-date align-right"><span class="hidden-sm">Last updated: </span><%= post.updated_at.strftime('%b %d, %Y') %></p>
      </div>
      <div style="clear: both;"></div>
      <p class="basic"><%= post.summary %></p>
      <p> </p>
      <p class="hype"><b>Read More</b></p>
      <p class="post-cat blog-index-date"><%= post.blog_category.name if post.blog_category_id.present? %></p>
    </div>
  <% end %>
</div>

CSS:

.media {
  padding: 10px;
  background-color: #404040;
  border-left: 4px solid #00BFFF;
  border-radius: 2px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

.media-title { margin-top: 0px }
.media-body { position: relative }
.post-react {
  opacity: 0.8;
  transition: .45s, transform .45s ease;
  -moz-transition: .45s, transform .45s ease;
  -webkit-transition: .45s, transform .45s ease;
}

.post-react:hover {
  opacity: 1.0;
  -ms-transform: scale(1.01); /* IE 9 */
  -webkit-transform: scale(1.01); /* Safari */
  transform: scale(1.01);
}

.blog-index-date {
  padding-right: 5px;
  color: #999999;
}

.post-cat {
  position: absolute;
  bottom: 0px;
  right: 5px;
}

.news-object { border-radius: 2px }

First Load: https://i.sstatic.net/rNgjh.png

After Refresh: https://i.sstatic.net/kFAD0.png

This issue has persisted for a few weeks now. Appreciate any assistance you can provide!

Answer №1

After some investigation, it appears that the positioning issue was due to the placement of my stylesheet link in the code. Initially, there were other elements before it, such as google analytics, which may have caused delays in loading.

I made a simple adjustment by moving the stylesheet link:

<%= stylesheet_link_tag "bootstrap.min", "application" %>

By repositioning the link above google analytics, the problem with positioning was resolved successfully.

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

Ways to resubmit a HTML form

UPDATE: I made a silly error. Accidentally used some outdated code where the 'start' function became inactive after being clicked. It's all sorted out now. Lesson learned: meticulously review your code line by line, especially if it's a ...

Element that fades out gradually

I have been experimenting with fading out elements using the following code: $('[title!="head"]').each(function () { $(this).fadeOut(100); }); However, I noticed that all elements, including those with $('[title="head"]'), are bei ...

Disable reloading when submitting and reset input fields after submission

I am working on developing a website where users can post things and comments without the need to refresh the page. I have encountered some issues while implementing this feature and need some assistance with it. My goal is to allow users to submit comment ...

Why is my Angular router displaying the page twice in the browser window?

Angular was initially loading the page on the default port localhost:4200. I wanted it to serve as localhost:4200/specialtyquestions when the app builds, and that is working, but the pages are appearing twice in the browser. Any ideas on what might have be ...

Tips for preventing the headers of a table from scrolling

I am currently working on a solution to keep the header of my table fixed in place without scrolling. Despite my limited experience with Bootstrap and React, I have tried exploring older threads on Stack Overflow to find a suitable fix for making the head ...

Is IE8 compatible with HTML5 and CSS3?

My client has requested their website to be developed using HTML5 and CSS3. However, it has come to my attention that IE6 and IE7 do not have full support for HTML5 and CSS3. The client claims that IE8 does support these technologies, but I need more inf ...

Updating the functionality of Bootstrap 4 accordions

Utilizing HTML templates based on Bootstrap 4.3.1, I am delivering educational content to my students. In the current setup, all accordion panels are closed when the page loads, and each panel can be opened independently of others. To see a live example, ...

Using a Django "for" loop to iterate through dates

Running my blog app has been a smooth process so far. I've implemented the following code snippet: {% for entry in entry.all %} <div class="timelinestamp"> ... </div> ...

Is there a way for me to automatically close other menus when the current menu is open using slideToggle?

Seeking assistance with enhancing the navigation functionality. How can I ensure that when a user clicks on a menu item, any other open menus are closed and the active class is removed from them? The current navigation setup meets my requirements except ...

Selecting one, multiple, or all checkboxes and attempting to proceed by activating the button will not function as intended

The functionality of the "check all" / "uncheck all" button allows me to easily select or deselect all checkboxes within my form. The "proceed..." button should become active once one, multiple, or all checkboxes are checked. While this feature works smoo ...

Whenever I try to make my links responsive, they don't seem to work as intended

This is the HTML snippet <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> ...

Adjustable dimensions for slider images

My goal is to add a rotating slider to my website, but I'm facing an issue where it needs to occupy the entire screen on both mobile and desktop devices. However, setting the width to 100% makes the image not visible. I am utilizing code from this lib ...

What is the proper HTML tag and syntax used for adding a text box within the content of a webpage?

Question about HTML: How can I add a text box or block to an HTML page that is filled with plain text? I want the text box to align to the right and be surrounded by the plain text, essentially wrapping around it. I also need to specify the dimensions of ...

Customize the fieldset style in Bootstrap 5

In earlier versions of Bootstrap (or with plain CSS), the following HTML code used to result in a fieldset with a visible border, where the legend sat on top: <fieldset> <legend>Test</legend> Welcome! </fieldset> Here is how ...

Error prevents the image from being displayed on this page

I'm having trouble displaying a background image within a div: <div class="container-fluid"> <div class="row"> <div class="fill-screen" style="background-image: url('../../wwwroot/imag ...

Image container unable to resize to fit within a CSS grid cell

I'm currently working on organizing a CSS grid for my images on a tribute page project from free code camp. I was able to set up the grid as intended, but I am facing some difficulties in making the images fit perfectly within each cell. Some images a ...

Aligning a list in the center without adding any indentation

So, I have this list that I want to center using some CSS magic. I did some searching and found a solution to remove the list style and left margin. But I really want to make sure it's perfectly centered, so I added text-align:center;. However, I not ...

Accordion with searchable tabular layout

Can you search for a product within an accordion? I have 34 categories in my accordion, each with a table containing at least 10 rows. Each row has a column with an icon that stores the data of that row. Please note that I am not using jQuery tables. If ...

text: vertical placement of divs instead

I am struggling to position my platform divs, each with 3 children-divs, horizontally inside the wrapper div. Despite setting the '-webkit-box-orient' property to horizontal for both the platform div and its children, I cannot get it to work. Any ...

Discover the default text highlighting color of a browser with the use of JavaScript or Dart programming

Did you know that you can change the browser's default text highlight (selection) background color using CSS? For example: ::selection { background: #ffb7b7; } Find out more about the browser/OS specific default background color when selecting tex ...