Flexbox/Bootstrap column with the option to include a vertically centered span text suffix

Is there a way to display an optional text suffix within a vertically centered flexbox/bootstrap column, specifically only on small screens? The current code I have works using "display:contents" on the span-element, but this isn't universally supported by browsers. Without using "display:contents", the text suffix ends up displayed as another column instead of flowing with the previous text. Is there a different approach to achieve this desired effect?

<div class="row">
   <div class="col-2">
      <img src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" width="100" height="300">
   </div> 
   <div class="col d-flex align-items-center">
        Title text Title Text 
        <span class="d-lg-none" style="display:contents">
           (Optional column is here on small devices)
        </span>
   </div>
   <div class="col-2 d-none d-lg-flex align-items-center">
      Optional column
   </div>
</div>

https://jsfiddle.net/9z81tvsx/

Answer №1

Understanding d-flex as display:flex;

This particular element organizes its contents through flow layout, combining block and inline layouts.

In scenarios where its outer display type is inline or run-in, and it takes part in a block or inline formatting context, an inline box will be generated. Otherwise, a block container box will be created. Learn more on Mozilla Developer Network

The usage of .d-flex on the parent results in display:block for span.d-lg-none on small screens, causing it to act like a column.

To address this issue, consider enclosing the text within a Paragraph element.

<p>Title text Title Text <span class="d-lg-none">(Optional column displayed on small devices)</span></p>

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

Transform an iOS WebView into a user-friendly ebook reader

Typically, in a webview, you can scroll vertically like a browser if the page is too long. However, I am interested in transforming this experience to mimic an ebook reader. Rather than scrolling down, I would like users to be able to swipe to the next pag ...

Ways to enhance the resilience of the max-width property when utilizing PHP calls or dynamic CSS styling

I attempted to customize the CSS in page builder mode by adding the following code: #content { max-width: 2000px; } While in page builder mode, the desired effect was achieved. However, once I published the changes, the page reverted back to the prev ...

show information on a separate screen following the selection of a choice

After selecting an option, how can I make #formid appear where the form is filled in with the stock selected in the option section? <div class="form-group"> <label for="exampleFormControlSelect1">Item Name</label> <select clas ...

Tips on customizing the CSS responsiveness of your Bootstrap carousel

I have recently installed a Bootstrap theme on my Wordpress site and I am trying to make some CSS adjustments. One issue I am facing is with the carousel. Currently, when I resize the website or view it on a mobile device... The carousel maintains a lar ...

Tips for executing a function on a specific class selector using the document.getElementsByClassName method

When I click on a specific class, I want to implement a fade-out function in JavaScript. However, I am struggling to make a particular class fade out successfully. I attempted to use the this keyword, but it seems like I might be using it incorrectly bec ...

After refreshing the page, Google Chrome finally displays the CSS styles correctly

I'm currently working on a JavaScript script to showcase images on a webpage. These images are loaded using an AJAX request and a CSS style is directly applied using jQuery. The script functions correctly on Firefox, Opera, and IE, but Google Chrome i ...

Select DOM Elements Using JavaScript CSS Queries

As I delved into JavaScript in an attempt to craft my personal slider, I stumbled upon a perplexing discovery. I encountered a CSS regulation that looked like this: html.js #slideshow .slides img { position: absolute; } The explanation suggested that ...

Ways to Utilize CSS for Substituting Text

Is there a way to change Type: to Class: using CSS? <span class="skills">Type:<a href="....../type/aaa/">aaa</a>, <a href="...../type/bbb/">bbb</a></span> ...

What is the best way to prevent input fields from wrapping onto a new line in a Bootstrap 4 inline form layout?

I am facing an issue with my inline form where the input fields are wider than the screen, causing some of them to fall onto a new line. <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="u ...

JQuery along with Font Awesome: Setting the default value for star rating

The Situation: I am currently working on a system where users can rate various products using Laravel. Each product has an average rating which is then used to display stars. These ratings are shown on the "Product Listing" page, which contains multiple p ...

Setting up meta tags in React for optimal search engine optimization

In the process of developing a React app with react router, I encountered the need for SEO optimization and adding meta tags to each page. Despite trying out react helmet, it seems that the Yandex micromarkup validator (located at https://webmaster.yandex. ...

Troubleshooting CSS Problems: Issues with background repeating and footer placement

I am currently in the process of transitioning my website to a CSS layout, and so far it's looking good. However, I am facing two specific issues with the page layout that I need help with: 1) The background image of the left-most column is not repea ...

Position the AdMob banner at the bottom of the page

I am attempting to place an AdMob banner at the bottom of my page, but the Ad is not appearing. There seems to be space allocated for it, but the AdMob banner is not displaying. Include and reference the Google Play services library. - CONFIRMED Add a me ...

Is it possible to selectively add Bootstrap classes to certain sections of a pre-existing website without changing the current styling in place?

What is the best way to customize Bootstrap classes for specific blocks or modify default classes, like changing .row to .row_2, without impacting other elements styled with different Bootstrap classes? ...

Is there a way to add CSS styles to all div elements except for those that are contained within a parent div with a certain class

I have a universal CSS that impacts all div elements, but I need to exclude the divs within a parent div that has a specific class, like in this instance where it's the "should-not-apply" class. div { font-size: 20px !important; font-weight: 50 ...

What is the best way to include a maximum height in my ScrollToBottom element?

I am currently attempting to limit the maximum height of my component as adding user messages causes it to expand and stretch the whole page. However, I have been unsuccessful in setting a maxHeight property for the component. I am utilizing ScrollToBottom ...

What could be causing this unexpected delay?

I have been working on improving the load time of my website as it was quite lengthy, but even after optimizations, I am facing issues specifically with the jQuery UI CSS images. If you could spare a moment, would you mind taking a look at this Pingdom te ...

Avoid using the table and table-striped classes when working with Bootstrap 5 to ensure a

Recently updated to bootstrap5.0.0-beta3 along with bootstrap-table 1.18.2 from webjars repository. Here's the code snippet: <table id="table">...</table> <!-- no classes here --> $('#table').bootstrapTable({ ...

The navigation bar isn't turning into a hamburger menu - using bootstrap and Flask

My mobile responsive navbar is not rendering correctly on smaller screens. Check it out here: I am using Bootstrap Material Design with Flask and this is the code snippet for my nav-bar: <!-- Navbar --> <nav class="navbar navbar-expand-lg na ...

How come the sticky header isn't functioning within form tags with Bootstrap 4?

Why are the form inputs or buttons overlapping my navigation header? Everything works fine when I don't use bootstrap 4. I need the header to always be on top of all elements in my website. Is there a way to resolve this using only Bootstrap without ...