Turn Columns into rows with bootstrap

Asked

Viewed 301 times

1

I have a table in HTML using Bootstrap:

inserir a descrição da imagem aqui

With the code in CSS below I get it to automatically hide fields the last 3 columns when the page is resized to a resolution of 600 (width):

<style>
    @media screen and (max-width: 600px) {
        table th:nth-child(3),table th:nth-child(4),table th:nth-child(5) {
            display: none;
        }
        table td:nth-child(3),table td:nth-child(4),table td:nth-child(5) {
            display: none;
        }
    }
</style>

Thus remaining:

inserir a descrição da imagem aqui

But I’d like it to stay that way:

inserir a descrição da imagem aqui

And when I just clicked on + stay that way:

inserir a descrição da imagem aqui

Have to do with bootstrap or javascript?

  • I believe you will be able to do this with javascript. Because Bootstrap as far as I know does not work with click event.

  • @Diemanonóbrega Can be in javascript even

  • @Diemanonóbrega, Bootstrap is a library using Jquery, which is a library for javascript

  • @Gleysonsilva, I believe that it will not be possible the way you want, what can be done is, create a modal, that when clicking on the "+" button will bring in itself a copy of the hidden data of the table

  • @True diemanonóbrega, ended up being redundant.

  • 1

    @Murilogambôa good idea I will try like this, however, I thought of the other way for finding it easier to implement, of course, if there was a way for him to change the table without me having to make code for every table I have in the system.

Show 1 more comment

1 answer

1


This type of behavior is better to use javascript or Angularjs. With Angular you can create this type of behavior and reuse it faster.

  • If possible would like to use javascript, but otherwise it can be Angular even, you could post an example or indicate some site?

  • I believe this video can give you an idea of how to solve this problem: https://www.youtube.com/watch?v=t9bw7vWSKVE

  • thanks for the help, but since I have not seen anything of Angularjs and the project does not use this Framework, I did not think it was a good idea to use it only for this purpose. I will continue searching how to do in CSS and/or Javascript.

  • 1

    after analyzing the angular 2.0 I saw that it is more profitable to invest in it than to continue with Javascript, Jquery, Bootstrap without using a Framework.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.