Prevent the content within a Bootstrap "row" from moving to a new line

My website appears differently in desktop and mobile view.

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

While the tags align perfectly on desktop, they overflow onto a new line in the mobile view. Specifically, #pytorch and #tensorflow are pushed to a new line which I want to avoid. If the tags cannot fit on one line, I prefer to hide the excess ones like #pytorch and #tensorflow.

Here is a snippet of the code:

        @import url('https://fonts.googleapis.com/css2?family=Work+Sans:wght@430&display=swap');

        .main {
            max-width: 1200px;
            margin: 0 auto;
                /* more CSS rules here */
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b8dad7d7cccbcccad9c8f88c968d968b">[email protected]</a>/dist/css/bootstrap.min.css"
        integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
        <!-- more head elements -->
</head>

<body>

    <div class="container">
        <div class="main" style="padding-top: 3%; padding-bottom: 5%;">
            <div class="blog-card">
                <div class="row" style="background-color: #fff; padding-top: 1%;">
                    <div class="col-md-4">
                        <img src="https://mlthon.pythonanywhere.com/media/guides/img/carbon_2.png" 
                            style="max-width: 100%; height: auto; border-radius: 7px; padding-bottom: 3%;">
                    </div>

                    <div class="col-md-8">
                        <a href="/article/Loading-Really-Large-Datasets-Efficiently-With-Generators-Pytorch-and-TensorFlow"
                            style="text-decoration: none;">
                             <!-- more HTML content here -->
                        <p>Tags:</p>

                        <!-- Tags with issue -->
                        <div class="tag">
                            <p style="font-family: 'Dosis'; font-size: 1rem; color: #008AFF; cursor: pointer;"
                                onclick="tag('deep-learning')">
                                &nbsp;&nbsp;<span>#deep-learning</span></p>
                        
                         <!-- more tags -->

                        </div>

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

</body>

</html>

Answer №1


The main issue arises from the fact that the readme block is floating right outside of the row, which itself lacks width. One solution is to introduce a col-md-12 class within the row to ensure full-width tags, but this can cause the read more section to shift out.

If you prefer a CSS Flexbox-based approach, I would recommend creating a custom solution. However, with Bootstrap, you can try the following:

<div class="row">
<div class="col-md-auto order-md-12">
read more here
</div>
<div class="col-md-auto order-md-1">
tags here
</div>
</div>

This code will display both the read more and tags side by side on medium and larger screens, positioning the read more section at the end.

On smaller screens, both columns will take up full width, with read more appearing before the tags.

I've implemented this modification using your sample as reference.

Note that while the current setup works reasonably well, it's worth considering the semantic meaning of each element used. For instance, use <a> for links instead of onclick handlers, employ <ul><li> for lists, and wrap paragraphs in <divs> when necessary based on their context. If simplicity is preferred, a basic list of <a> elements may suffice for the tags.

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

Delete any additional input forms

I have recently developed a function to dynamically add an input field to my form: function add_parameter(){ var d = document.getElementById("content"); d.innerHTML += "<br/><br><div class='custom_search col-md-5'><sp ...

Transform Arabic numerals into Roman numerals using only CSS styling

Currently developing a custom theme for a website and faced with the restriction of not being able to use Javascript. My goal is to translate certain numbers into Roman numerals. I attempted the following: .score:before { counter-reset: mycounter att ...

The functionality of my website is currently experiencing difficulties when accessed through the Android UC Browser

My website, , is experiencing issues with product loading and the '+' button in the side menu not working on UC Browser. It works fine on other Android browsers like Chrome and Firefox, but I am confused as to why it is not functioning properly o ...

Organizing Checkbox Groups for Validation in Bootstrap

My form consists of 2 checkboxes and I only want to submit the form if at least one checkbox is checked. The current code requires both checkboxes to be checked, but I tried grouping them using the name attribute without success. How can I group checkbox ...

Changing the li tag by clicking on it is a simple task that can be easily

Whenever I click on a tag, I want the li class to change to "active" and open a new page with the corresponding tag as active. For example, if I click on the Overview tag, the new page should open with the li tag as active. I have attempted to write some c ...

Why is Validators.pattern not functioning in production when it works perfectly in my local development environment for Angular?

Why is Validators.pattern not working in the production environment but functioning fine in my local development setup? I implemented Validators.pattern and '*ngIf="email.errors.pattern"' for email validation on an existing form. Every ...

Using JAVA to generate SVG images, then embedding them into HTML using Base64 encoding URI

I am currently developing a service to generate SVG images. The main criteria is that the generated SVG must be compatible with an img tag (with the added bonus of working in a script tag) and it needs to function without the use of JavaScript. After some ...

Enable synchronized scrolling and a fixed/sticky header with splitpanes feature

Sandbox.vue <template> <v-container fluid> <Splitpanes class="default-theme" style="height: 400px" > <Pane v-for="i in 2" :key="i" > & ...

Trouble with CSS Class Showing Up Only When Hovered

My goal is to make the .panel-text element visible only when a user hovers over the panel. I attempted to use the overlay CSS class, but I encountered issues where the text either wouldn't show at all or would always be displayed. Here is what I have ...

Unable to return data to HTML page

I'm utilizing EJS to pass some data to my webpage. Here's the snippet of code: app.post('/ttt', function (req,res){ res.render('index.ejs', {titles: 'CAME IN'}) }); HTML <form id="mc-form" action="http://loc ...

Updating Button Text with PHP on WooCommerce

Hi there, I'm trying to find a way to translate a button in my WooCommerce store without using LocoTranslate or any other tools. Is there a PHP function that can help me change the button text without needing an ID? If you want to take a look at the ...

Tips for positioning images in the center of a footer

Hello, I am new to coding and would like some help adjusting the code for this website: The footer section at the bottom of each page features a row of logos. My goal is to make sure that these logo images display properly on mobile devices (without dropp ...

Why isn't the background image showing up on iOS devices when using the slider?

The website's background image displays on all devices such as laptops and Android phones, but not on iOS mobile devices. I even resized the image to 768px * 365px, but it still doesn't work. .bg-img { position: absolute; left: 0; ...

The custom marker created with Leaflet using divIcon does not seem to be styled with the specified

I'm currently working on customizing the leaflet marker using a divIcon and custom HTML. My aim is to have my marker displayed similarly to this example: https://i.sstatic.net/a5RnY.png So far, I've managed to create a marker and a divIcon with ...

Unable to conduct this search with Python using Selenium on a website

I have written a script to search for books on a webpage using Selenium: from selenium import webdriver from selenium.webdriver.common.keys import Keys import time PATH = "C:\Program Files (x86)\chromedriver.exe" driver = webdriver.Chrome(PATH) ...

Modifying the chart width in Chart.js: A step-by-step guide

After creating a chart using Chart Js, I encountered an issue where the chart did not fit within the specified width. Adjusting the attributes of canvas proved to be ineffective, specifically with regards to the width attribute. Despite changing the value, ...

Determine if the chosen option is present in any of the four arrays using Jquery/HTML, and execute a specific function based

I've been searching the web and other questions for assistance with this, but I can't seem to figure it out. I suspect that I'm not using the correct keywords. My goal is to create a functionality based on a value selected by a user from a ...

An alternative to PHP's exec function in Node.js

I am interested in developing a piece of software using C (such as prime number factorization) and hosting it on my web server with Node.js. Following that, I would like to create an HTML document containing a form and a button. Upon clicking the button, ...

saving information into a MySQL database

I am facing an issue where I am trying to write data to MySQL. When I input the data and press the submit button, the console log message from the function indicates that everything is okay. However, upon checking the database, there is nothing saved. Can ...

Using Selenium to stream audio directly from the web browser

For my current project, I am utilizing Selenium with Python. I have been exploring the possibility of recording or live streaming audio that is playing in the browser. My goal is to use Selenium to retrieve the audio and send it to my Python application fo ...