A guide on implementing animated column resizing in Bootstrap 4

I am working with a layout structure that consists of a row with two columns. At the beginning of the page, I want to display only one column with full screen width, so I have set it to col-sm-12. However, once a specific event is triggered, I need to show the right side column with its width set to col-sm-4, and the main column (initially set to col-sm-12) should shrink to col-sm-8.

The layout appears as follows:

$('.main').on('click', function() {
  $('.main').removeClass('col-sm-12')
  $('.main').addClass('col-sm-8')
  $('.side').removeClass('d-none')
})
html,
body {
  height: 100%;
}

.main {
  background-color: #ff23;
}

.side {
  background-color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4e2c21213a3d3a3c3a312a32272d206562637ca03b">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous" />
<div class="container-fluid h-100">

  <div class="row h-100">
    <div class="col-sm-12 main">

    </div>
    <div class="col-sm-4 d-none side">

    </div>
  </div>


</div>

How can I animate the transition in column width from col-sm-12 to col-sm-8? I would like something where the hidden column pushes the other by stretching or utilizing another type of fancy animation...

Answer №1

My suggestion would be to use the transition css property for your specific case, although I cannot guarantee it will work. You can try setting:

div[class*="col-"] { transition: .3s ease; }
and see if that helps. Please keep me updated on the results.

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

Having trouble deciphering the API or a specific one from React.js/Node.js/Axios/Fetch?

I'm facing some confusion regarding my code. I have tried different APIs and some work, while others cannot be accessed in react.js. Can anyone help me correct this issue? The APIs that are not working in react.js always return a typescript fetching f ...

Utilizing ng-repeat, filter, and the uib-popup-datepicker to refine and display specific data within a table column

I'm currently facing a common scenario in my Angular application where I need to filter items from an ng-repeat using an HTML5 input of type 'date' or Angular-UI-Bootstrap's 'uib-popup-datepicker'. Despite extensive research, ...

Javascript canvas producing a laser beam that serves no purpose

Greetings! I am diving into JavaScript and trying my hand at creating a game. The concept is simple - a ship shooting lasers at alien spacecrafts. However, I've encountered a problem with the destroy function that has left me scratching my head. Surpr ...

Accessing the AppContext in Next.js within the _document file is the

My challenge with using next js is the occurrence of Content-Security-Policy issues due to the inline styles it utilizes. If 'unsafe-inline' is not added to the style-src, you will encounter the error message 'Refused to apply inline style ...

Adding up the values of an array of objects by month using ReactJS

To start off, I'm using ChartJS and need to create an array of months. Here's how it looks: const [generatedMonths, setGeneratedMonths] = useState<string[]>([]) const [totalValues, setTotalValues] = useState<number[]>([]) const month ...

implementing a timestamp in a specific timezone with Vue.js

Utilizing a timestamp attribute, I have successfully implemented the display of the current time and date on my webpage. Is there a way to showcase this information in a specific time zone? I am looking to present it in the ZULU timezone, which remains st ...

When going through an array using jquery, only the final object is returned

I am diving into the world of jQuery and dealing with what seems to be a basic issue. <input type="text" name="text1" value=""></input> <input type="text" name="text2" value=""></input> <input type="text" name="text3" value=""&g ...

Is it better to have JavaScript and HTML in separate files or combined into a single HTML file?

Do you notice any difference when coding in both HTML and JavaScript within a single .html file compared to separating HTML code in a .html file and JavaScript code in a .js file? Does the functionality remain the same in both scenarios? For example, in t ...

Error with Jquery authentication

Take a look at the code snippet below: var jsonData1 = $.ajax({ url: 'http://'+domainName+':9898/jolokia/read/*', dataType:"json", crossDomain: true, beforeSend: function(xhr){ var username= '*&a ...

The background-size:cover property fails to function properly on iPhone models 4 and 5

I have taken on the task of educating my younger sister about programming, and we collaborated on creating this project together. Nicki Minaj Website However, we encountered an issue where the background image does not fully cover the screen when using b ...

Django: The Art of Rejuvenating Pages

Consider the following code snippet which updates the timestamp of a database model whenever it is accessed: def update_timestamp(request): entry = Entry.objects.filter(user=request.user) entry.update(timestamp=timezone.now()) return HttpRespo ...

Enhancing JSON Objects in AngularJS with Custom Properties and Calculations

Hello, I'm still getting the hang of angularjs and could use some guidance. I have a Rest service that provides data on saleItems when a get request is made, as shown below: saleItems = [ { "id": 236, "variant": "Oval Holder", "mrp": "6 ...

Utilizing JavaScript to Connect with REST API

Looking to access a REST API from JavaScript code, using jQuery's ajax method: function tryQwintry () { var data = { "params[weight]" : "100", "params[dimensions]" : "100x100x100", "params[delivery_pickup]" : "msk_1", ...

Show on Screen as Label Text

I am looking to change the display format from a popup box to a label text. How can I achieve this using JQuery? JQuery <script type="text/javascript> function ShowCurrentTime() { PageMethods.GetCurrentTime(document.getElementById("<%=txtUserNam ...

removing duplicate items from an array in Vue.js

I created a Pokemon App where users can add Pokemon to their 'pokedex'. The app takes a pokemon object from this.$store.state.pokemon and adds it to this.$store.state.pokedex. However, users can add the same pokemon multiple times to the pokedex, ...

Reorder columns according to the device type

Seeking advice on reordering content based on user device. Preferred order for mobile: A B A B Preferred order for PC: A B B A Attempts made so far: <div class="row"> <div class="col-sm-5 col-sm-pull-5"> ...

Disable browser autocomplete for Material-UI TextField

I am currently using Material UI version 0.20.0 and I am facing an issue where I need to prevent the password from being saved for a user in a TextField. I tried adding props to the TextField with autocomplete='nope' since not all browsers suppor ...

Unexpected issue with Ajax form submission when using the submitHandler function in Jquery

I am faced with the challenge of validating a form using the jQuery Validation Plugin and submitting data to a database without refreshing the page. Despite marking all fields in my form as required, the issue arises where empty fields are still submitted, ...

Merge two separate arrays to create a new associative array

I'm faced with the challenge of merging two arrays of data obtained from an HTML form. The first array (payment_descriptions) is structured as follows: ["1st Desc","2nd Desc","3rd Desc"] While the second array (payment_ ...

The behavior of Quasar's q-drawer is quite unpredictable

Having made the transition from Vue.js 2 with Vuetify to Vue.js 3 with Quasar due to Vuetify not officially supporting Vue.js 3 yet, I am utilizing q-drawer and its mini property. This allows me to toggle between the mini state and the normal expanded stat ...