On mobile devices, the text is showing up without the image, while on desktops the image is displaying correctly alongside the text in

I have designed a responsive UI page using bootstrap, featuring a responsive image on the left side and text on the right side of the section.

Currently, the image appears on desktop but not on any mobile device when tested using developer tools.

Below is the code for the image that is not showing on mobile devices:

<img class="w-100 " src="<?php echo get_template_directory_uri(); ?>/images/tablesetting.jpg" alt="Thefirstpics">

For the complete code, refer to the following:

  <!--About Dine section 1-->
  <section class="about_sec_1 ">
    <div class="container ">
      <div class="  about_content">
        <div class="left_img col col-lg-5">

<img class="w-100 " src="<?php echo get_template_directory_uri(); ?>/images/tablesetting.jpg" alt="Thefirstpics">



      </div>
        
        <div class="right_content col  col-lg-6">
          <div class="text-center">
    <h1 class="pb-5"><?php echo esc_html(get_post_meta(get_the_ID(), 'about_title', true)); ?></h1>
    <h4 class="pb-3"><?php echo esc_html(get_post_meta(get_the_ID(), 'about_subtitle', true)); ?> </h4>
          </div>
          <p class="about_para ">
            The Catering was founded in blabla by Mr. Smith in lorem ipsum dolor sit amet, consectetur adipiscing elit
            consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
            minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            iruredolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.We only use
            seasonal ingredients.
          <p class="text-muted">
            Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
            laborum consectetur adipiscing elit, sed do eiusmod temporincididunt ut labore et dolore magna aliqua. Ut
            enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
          </p>
          </p>
        </div>
      </div>
    </div>
  </section>

  <!--end of About Dine section 1-->

The CSS code can be found below:

/* media querie for about dine section img*/
@media(max-width:575px) {
    .left_img {
    display:block;

    }
}

.about_content,
.menu_content {
    /*make two column content of menu and about section by using flexbox*/
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3.5rem;
}

.about_para {
    line-height: 30px;
}

Refer to the images of the section below:

https://i.sstatic.net/yryRxhB0.png

Here's how it looks on mobile: https://i.sstatic.net/QSIUiD2n.png

Answer №1

Hey, don't forget to wrap your .col divs inside a .row div as per Bootstrap standards.

You've tagged this question with both BS4 and BS5 tags... and these frameworks are quite different...

Based on your usage of the col class, I'm assuming you're working with BS5!

A general rule for both BS4 and BS5 is to nest your column divs within row divs.

@Nazar was correct about the invalid markup with that duplicate closing p tag.

However, your markup won't function correctly unless structured like this:

<section class="about_sec_1">
  <div class="container">
    <div class="row">
      <div class="col-lg-5">
        <img class="img-fluid" src="<?php echo get_template_directory_uri(); ?>/images/tablesetting.jpg" alt="Thefirstpics" />
      </div>
      <div class="col-lg-7">
        <div class="text-center">
          <h1 class="pb-5"><?php echo esc_html(get_post_meta(get_the_ID(), 'about_title', true)); ?></h1>
          <h4 class="pb-3"><?php echo esc_html(get_post_meta(get_the_ID(), 'about_subtitle', true)); ?></h4>
        </div>
        <p>
          The Catering was founded in blabla by Mr. Smith in lorem ipsum dolor sit amet, consectetur adipiscing elit consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute iruredolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.We only use seasonal ingredients.
        </p>
        <p class="text-muted">
          Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod temporincididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
          nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </p>
      </div>
    </div>
  </div>
</section>

Don't add unnecessary extra div elements around columns, rows, and containers in Bootstrap 5. Stick to the clean structure as shown in the documentation. Only introduce custom classes when needed inside BS5 columns without affecting responsiveness.

Also, if you're using a .col- column class, there's no need to redefine the .col class as all necessary CSS is included in the column class itself. Use .col only if you want the column to resize automatically without predefined grid structure :-)

Happy BootStrapping!

Answer №2

Make sure to check for any extra closing paragraph tags (</p>) in your HTML code and remove them if necessary to ensure proper structure.

<!--About Dine section 1-->
<section class="about_sec_1">
  <div class="container">
    <div class="about_content">
      <div class="left_img col col-lg-5">
        <img class="w-100" src="<?php echo get_template_directory_uri(); ?>/images/tablesetting.jpg" alt="Thefirstpics" />
      </div>

      <div class="right_content col col-lg-6">
        <div class="text-center">
          <h1 class="pb-5"><?php echo esc_html(get_post_meta(get_the_ID(), 'about_title', true)); ?></h1>
          <h4 class="pb-3"><?php echo esc_html(get_post_meta(get_the_ID(), 'about_subtitle', true)); ?></h4>
        </div>
        <p class="about_para">
          The Catering was founded in blabla by Mr. Smith in lorem ipsum dolor sit amet, consectetur adipiscing elit consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
          exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute iruredolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.We only use seasonal ingredients.
        </p>

        <p class="text-muted">
          Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod temporincidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
          nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </p>

        <!-- HERE IT IS -->
        <!-- </p> -->

      </div>
    </div>
  </div>
</section>

<!--end of About Dine section 1-->

Your CSS can be optimized by removing redundant styling that is not needed:

@media (max-width: 575px) {
  .left_img {
    display: block;
  }
}

No need to explicitly set display: block for a <div> element as it's already block-level by default.


To make your design more responsive, consider updating your CSS like this:

.about_content,
.menu_content {
  /*make two column content of menu and about section by using flexbox*/
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 3.5rem;
}

.about_para {
  line-height: 30px;
}

/*  */

.left_img.col {
  flex-basis: auto !important;
}

By setting flex-basis: auto, the .left_img.col element will adjust its size based on content and available space within the flex container, enhancing responsiveness when combined with flex-wrap: wrap.

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

The slide effect in jQuery's show() function isn't being displayed as expected

How can I implement a slide effect to hide and show an article element based on different navigation clicks? When loading the page, clicking on Home smoothly hides the article with no issues. However, when clicking on the About Us link, the article is imme ...

Pressing "Enter" after filling out a box on a form is like sending your

Have you ever noticed that when there is a button and a text field within the same form, pressing enter while the text field is active results in clicking the button? http://jsfiddle.net/cZcGE/ Why does this occur, and how can I make the text field behav ...

Manipulate the value of the <input> element when focused through JavaScript

After I focus on the input field, I was expecting to see Bond-Patterson, but instead, I am only getting Bond. What could be causing this discrepancy and how can it be fixed? $('input[name="surname"]').attr("onfocus", "this.placeholder='Bo ...

Uncovering a specific element within an array using knockout techniques

I am attempting to set a variable to an element within an array that holds a particular value for a property. For instance, I want to retrieve the item with an "Id" value of 15. However, my current method only retrieves the first item in the array, regar ...

Instead of clicking directly on the link, you can click anywhere on the div

How can I make it so the user can click anywhere on div.post instead of just on one of the actual a elements in the code below? <div class="post" style="padding: 20px; background-color: transparent;"> <div class="thumbnail" style="float: lef ...

Is it possible to automatically play a sound clip when the page loads?

Is there a way to automatically play a sound clip when my page loads? Are there any specific JavaScript or jQuery methods I can use for this, as I am developing my page using PHP. ...

Styling with CSS and Bootstrap: Looking to position two divs next to each other within another div

Here is my current code snippet: <!-- Masthead--> <header class="masthead"> <div class="container"> <div class="masthead-subheading" style="color: black;">Welcome</div> <div clas ...

Build a custom form for the purpose of exporting an HTML file

I am in search of a way to provide my users with various "feature" choices that will assist them in creating an HTML file for an email. I already have the code ready for each feature, but I want users to be able to select a feature (such as Hero Image Head ...

Issues with CSS rendering font in a suboptimal way

Whenever I set a simple font rule for my text, the output is not displayed correctly and appears blurry. The font looks fine in Mozilla Aurora browser but displays poorly in newer versions of Google Chrome and Firefox. Does anyone know why this happens? I ...

Automatically updating table inserts an extra row based on a specified parameter

for (let i = 0; i < 4; i++) { let tr = $('<tr/>'); tr.append("<td id=''>" + i + "</td>"); tr.append("<td id=''>" + i + "</td>"); tr.append("<td id=''>" + i + "</td> ...

Can we make one tab disappear when another tab is clicked in Ionic 2 app menu icon?

I am working on a project using Ionic 2 and I have implemented multiple tabs in the application. However, I need to find a way to hide the top tab when the user clicks on the bottom tabs menu icon. Here is my Plunker for your reference. My goal is to ma ...

Utilizing checkboxes to extract multiple columns from my MySQL database using PHP

Currently, I am able to extract the equipment name column from my table and insert it into my av_events SQL. However, I would like to also include the serial column in my av_bookings table equipment column since it serves as a unique identifier. While I a ...

Steps for designing a navigational bar with tabbed style that is responsive

Upon inspecting the sample code, you may have noticed that the .current class leaves a grey area at the bottom. I am trying to make it white all the way down, but every attempt to increase the size of the li also extends the ul. I'm facing an issue w ...

Is there a way to showcase the newly added state object on the page without having to reload the page?

I am currently showcasing the attributes (recipe title, image URL) of items from a state. These items originate from mongodb. Below is my current code flow: Create an empty array state variable named initialRecipes using const [initialRecipes, setRecipes] ...

The CSS overflow hidden attribute is leading to issues with the functionality of the Google Maps API

I am struggling to showcase a Google map as a tooltip using the qTip jQuery plugin. I have multiple elements on my page and need to assign overflow: hidden to all of them. Everything is functioning properly, except for the fact that the Google map toolti ...

Is the background image viewport centered?

I am embarking on a new venture with a website design that is unfamiliar to me, but I have a clear goal in mind... My design concept involves a single large image measuring 1000px x 1000px as the background, while the actual content fills up only 500px x ...

Tips for aligning text and images in a vertical baseline position

I am struggling to align text and three images vertically using the baseline. Even after applying the vertical-align property with text-bottom, the alignment issue persists. https://i.sstatic.net/UyQgI.png Refer to the screenshot with a transparent black ...

`Troubleshooting problems with Vue's v-model data binding`

I am experiencing an issue with setting a value in the vue data object using v-model when selecting a standard Bootstrap radio button pair. Interestingly, this setup works perfectly fine in a JSfiddle, but for some reason it fails to work locally on my ow ...

Sliding Dropdown Menu with Dynamic Title Change Upon Selection

I'm having an issue with a dropdown menu on hover that slides down and then back up. The active list item serves as the title of the dropdown. When a user clicks on an <li>, it becomes active and receives the class active-markup-style which sets ...

Update the image source within a CSS element

I'm facing an issue with changing the source image of an Element. The situation is that I have a customized CSS script and I need to modify a logo image. Below, you can find the source code: https://i.stack.imgur.com/8HLCE.png The problem lies in at ...