Customize Bootstrap layout on the fly

I have encountered a slight dilemma. I am attempting to implement something similar to the following:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>


<div class="container">
  <div class="row">
    <div class="col-xs-12">
      <div class="col-xs-3">Test 1</div>
      <div class="col-xs-3">Test 2</div>
      <div class="col-xs-3" ng-if="test">Test 3</div>
    </div>
  </div>
  
  <div class="row">
    <div class="col-xs-12">
      <div class="col-xs-3">Test 4</div>
      <div class="col-xs-3">Test 5</div>
      <div class="col-xs-3">Test 6</div>
    </div>
  </div>
</div>

Is there a straightforward way to ensure that when I disable the "Test 3" div using test, the "Test 4" div seamlessly takes its place? Although the actual code is more intricate, the essence remains the same – all elements must dynamically align to the left to prevent any empty space.

Answer №1

Combine all the col-* classes inside a single row.

<div class="container">
  <div class="row">
      <div class="col-xs-3">Test 1</div>
      <div class="col-xs-3">Test 2</div>
      <div class="col-xs-3" ng-if="test">Test 3</div>
      <div class="col-xs-3">Test 4</div>
      <div class="col-xs-3">Test 5</div>
      <div class="col-xs-3">Test 6</div>
    </div>
</div>

This technique is referred to as Bootstrap column wrapping.

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

Merge JSON objects while retaining duplicate keys

I am looking to merge two arrays containing JSON objects while retaining duplicate keys by adding a prefix to the keys. In this specific scenario, the data from 'json2' is replacing the data from 'json1' due to having identical keys, bu ...

Positioning Backgrounds with Padding in DIV Elements

I am trying to figure out how to add a check mark next to text in a button with specific styling. I have managed to get the check mark aligned properly using Background:left center, but I also want to add padding and adjust spacing. Is there a way to achie ...

Modifying the color of elements within a picture

I am in search of the perfect web technology or JavaScript library that can help me achieve a specific functionality. My aim is to change the colors of particular objects within an image. I am looking to create a tool where users can select a color, and th ...

What are the steps to implement $navigateTo() in a NativeScript Vue application?

What could be causing $navigateTo(Page) to not work? Visit this link for more information ...

Wait for the jQuery UI tabs to load until the entire HTML has been rendered

I have implemented jQuery UI tabs on my website. Occasionally, when the page first loads, all the HTML content for each tab is visible before the tabs themselves appear. This causes a slight delay in positioning the content within the tabs and creates an ...

"Displaying the state value retrieved from a custom hook is not working as expected

Creating a custom hook, Custom.js: import React, {useState, useEffect} from 'react'; import Clarifai from 'clarifai'; const app = new Clarifai.App({ apiKey: 'XXXXXXXXXXXXXX' }) const CustomHook = () => { const [i ...

Find an element within an array in a separate JavaScript file (leveraging AngularJS)

I am new to AngularJS and decided to create a custom map with my own markers that I defined. To do this, I started by creating a JavaScript file containing an array: var myMarkers=[{ method1='..', methode2='..' },{ method1=&a ...

Prevent Mui popover from closing when clicking outside

Currently, I have implemented Mui Popover with ReactJS from the link here. One issue I am facing is that when a user clicks outside the popover, it automatically closes. Is there a way to disable this default behavior? Additionally, I would like to add a ...

Unexpected display issue with Bootstrap-vue navbar component

I am currently working with bootstrap-vue and trying to implement a navbar component within my application. I followed the first example provided in the documentation at this link. All the necessary dependencies are installed as per the bootstrap-vue instr ...

Submitting an HTML form results in no data being sent

I am currently facing an issue with a form on my website. The form code is as follows: <form action="" method="post" id="login_form"> <input type="text" name="log_login_form"/> <br/> <input type="password" name="log_password_for ...

CSS: Adjusting the position of tooltips to align with the triggering element (rest of code is fully functional)

Looking to create a custom tooltip without relying on plugins. The goal is to align the tooltip vertically to the right of the triggering element, in this case, an input field. The current setup (see Fiddle demo) achieves the desired layout and content fo ...

I have noticed that the display:none property for <span> elements does not seem to work in IE8 on some computers, although it does

<span id='x' style='display:none;'> <input type=button value='x'> </span> <span id='y' style='display:none;'> <input type=button value='y'> </span> Although th ...

Unable to retrieve the string contained within an element - JavaScript object literal

I am currently facing an issue where I am attempting to retrieve the text content of two div elements with classes .class-date and .class-time, but I keep encountering an Uncaught TypeError stating "e.siblings is not a function". I believe this may be a ...

utilize images stored locally instead of fetching them from a URL path in a Vue.js project

Hey there fellow Developers who are working on Vuejs! I'm encountering something strange in the app I'm building. I am attempting to modify the path of image requests based on a particular result, which causes the images to change according to th ...

Executing Code Upon Module Load and Presenting It as Middleware

I am currently delving into the intricacies of how exporting and importing modules function in Nodejs. One of my tasks involves using a specific file to seed a mongodb database. Surprisingly, this file operates flawlessly and delivers the desired results ...

Is it possible in Elasticsearch to dynamically construct and send a JSON query object?

Currently I am utilizing angularjs alongside elasticsearch.angular.js. Constructing a dynamic JSON query object to reflect user requests has been successfully achieved. I am now seeking assistance on how to pass this constructed object to the search API wi ...

Tips on utilizing a local file as a background image URL

How can I modify my CSS to link to a local file path like C:\xampp\htdocs\Folder instead of the URL https://source.unsplash.com/1600x1050/?nature. I am currently using Bootstrap 4 and below is my CSS code: .jumbotron{ background: ...

Creating Dynamic Divs in ASP.NET

Attempting to dynamically create a Div by clicking a button has been a challenge for me. I found a helpful link here: After referring to the link, I created the following code on the server side (.cs page): public static int i = 0; protected void Bu ...

Converting JSON Data to Map Markers on Google Maps

Currently, I am attempting to pass a Json String into my Javascript code in order to create a list of markers on a Google Map. The map code functions properly as I have successfully tested it with a hard coded Json Object. However, now I need to fetch the ...

Using Node.js to schedule and send notifications to a specific topic via FCM

In order to deliver topic notifications to Android devices using FCM, I have set up an Angular application and a Node.js server. The scheduling of these notifications is handled by the bull library. The process involves two methods of sending notification ...