Utilize Bootstrap to enhance mobile functionality by transferring descriptions from column titles to row names

I'm currently working on optimizing a table for mobile responsiveness, and I've encountered an issue with the column titles.

Currently, on desktop view, the column titles are 'Display Color,' 'Up' and 'Down.' Ideally, when the layout switches to mobile, I'd like 'Up' and 'Down' to be displayed on the rows instead. So, instead of just "A:" in a row, it would show "A: Up" followed by "A: Down" or something similar. Is there a way to achieve this functionality using Bootstrap?

You can see what I mean by adjusting the width in this JS Bin example. Currently, when you resize to mobile size, it's not clear which dropdown corresponds to 'Up' and which one is for 'Down.'

Here's the code snippet:

<!-- views/profile.ejs -->
<!doctype html>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/stylesheets/main.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
        body        { padding-top:80px; word-wrap:break-word; }
    </style>
<script>
    <link rel="stylesheet" type="text/css" href="/js/scripts.js" />
</script>
</head>
<body>
<div class="container">

    <div class="row">
      <div class="col-md-4 text-left">
        <strong>Display Color</strong>
      </div>
      <div class="col-md-4 text-left">
        <strong>Up</strong>
      </div>
      <div class="col-md-4 text-left">
        <strong>Down</strong>
      </div>
    </div>

      <div class="row"> 
        <div class="col-md-4 text-left">
          <strong>A:</strong>
        </div>
        <div class="col-md-4 text-left">
          <select class="bootstrap-select btn col-md-12" name="color1U" autocomplete="off">

            <option name="name0" value="0" 
             >white<span class="colorRectangle"></span>
            </option>

            <option name="name1" value="1" 
             >red<span class="colorRectangle"></span>
            </option>

            <option name="name2" value="2" 
              >orange<span class="colorRectangle"></span>
            </option>


          </select>
        </div>          
        <div class="col-md-4 text-left">
          <select class="bootstrap-select btn  col-md-12" name="color1D" autocomplete="off">

            <option name="name0" value="0" 
            >white</option>

            <option name="name1" value="1" 
            >red</option>

            <option name="name2" value="2" 
            >orange</option>

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

      <div class="row"> 
        <div class="col-md-4 text-left">
          <strong>B: </strong>
        </div>
        <div class="col-md-4 text-left">
          <select class="bootstrap-select btn col-md-12" name="color2U" autocomplete="off">

            <option name="name0" value="0" 
             >white<span class="colorRectangle"></span>
            </option>

            <option name="name1" value="1" 
            selected="selected" >red<span class="colorRectangle"></span>
            </option>

            <option name="name2" value="2" 
             >orange<span class="colorRectangle"></span>
            </option>

            <option name="name3" value="3" 
             >yellow<span class="colorRectangle"></span>
            </option>

          </select>
        </div>          
        <div class="col-md-4 text-left">
          <select class="bootstrap-select btn  col-md-12" name="color2D" autocomplete="off">

            <option name="name0" value="0" 
            >white</option>

            <option name="name1" value="1" 

              selected="selected">red</option>

            <option name="name2" value="2" 
            >orange</option>

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

    <input type="submit" value="Save"/>
  </form>
</div>
</body>
</html>

Answer №1

Check out this code snippet and let me know if it fits your needs:

<h1>
  Resize Window
</h1>

<table>
  <thead>
    <tr>
      <th>#</th>
      <th>Company</th>
      <th>Name</th>
      <th>Country</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td data-th="Sr. No.">1</td>
      <td data-th="Company">quality designs</td>
      <td data-th="Name">Eugene silinda</td>
      <td data-th="Country">South Africa</td>
    </tr>


  </tbody>
</table>

Link to see the code in action

Answer №2

Give this code snippet a try

<div class="container">
<div class="row">
  <div class="col-md-4 text-left">
    <h4>Color Display</h4>
    <p>A:</p>
    <p>B:</p>
  </div>
  <div class="col-md-4 text-left">
    <h4>Upward</h4>
    <select class="bootstrap-select btn col-md-12" name="color1U" autocomplete="off">
        <option name="name0" value="0">white<span class="colorRectangle"></span></option>
        <option name="name1" value="1">red<span class="colorRectangle"></span></option>
        <option name="name2" value="2">orange<span class="colorRectangle"></span></option>
    </select>
    <select class="bootstrap-select btn col-md-12" name="color1U" autocomplete="off">
        <option name="name0" value="0">white<span class="colorRectangle"></span></option>
        <option name="name1" value="1">red<span class="colorRectangle"></span></option>
        <option name="name2" value="2">orange<span class="colorRectangle"></span></option>
    </select>
  </div>
  <div class="col-md-4 text-left">
    <h4>Downward</h4>
    <select class="bootstrap-select btn col-md-12" name="color1U" autocomplete="off">
        <option name="name0" value="0">white<span class="colorRectangle"></span></option>
        <option name="name1" value="1">red<span class="colorRectangle"></span></option>
        <option name="name2" value="2">orange<span class="colorRectangle"></span></option>
    </select>
    <select class="bootstrap-select btn col-md-12" name="color1U" autocomplete="off">
        <option name="name0" value="0">white<span class="colorRectangle"></span></option>
        <option name="name1" value="1">red<span class="colorRectangle"></span></option>
        <option name="name2" value="2">orange<span class="colorRectangle"></span></option>
    </select>
  </div>
</div>

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

The nested navigation link disappears suddenly on Internet Explorer 9

This query closely resembles another issue: Nested menu keeps vanishing on IE 8 & 9. However, the solution provided is quite limited. Why do my nested menus disappear before I can reach them with my cursor unless I move it swiftly? This peculiar behavi ...

Struggling to make css selector acknowledge the margins on the right and left

I am trying to style two inner divs within a containing div by floating the first one to the left and the second one to the right. Additionally, I want to add a margin of 15px on the left for the first div and on the right for the second div. The challenge ...

Display the chosen alternative in a Bootstrap dropdown menu

I am currently facing an issue with the dropdown list in my bootstrap menu. <li class="dropdown"> <a aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" class="dropdown-toggle" href="#">Chose option<span class="c ...

Position the text in the center of a graph within a grid cell by utilizing dash and plotly

Is there a way to center text over a graph within a cell of a grid table using dash and plotly? I'm struggling with the alignment currently, as the graph is not centered while the text appears centered in the view but not in the cell itself. You can ...

Tips on creating a resizable box that can move from left to bottom and also from right to top

Hey there, I'm currently working on developing my own catalog and I'm in the process of creating a selection tool to allow users to zoom in on a specific part of an image. If you're interested, you can check out the project here. However, I ...

Alignment of inner div within the footer

I'm struggling to align my footer navigation inline with my footer title. Check out this code snippet to see what I've tried so far: https://jsfiddle.net/nkzsufov/ I experimented with using absolute and relative positioning: .footerNav { margi ...

What is the best way to resize an image for mobile site optimization?

I've been struggling with resizing an image by its width for different mobile devices even after trying to search on Google. Here's what I have attempted: CSS: img.test { width: 100%; height: auto; } HTML: <html> <head> ...

Begin your journey with Foundation Navigation as it seamlessly transitions from left to right

I am currently working on this navigation: I am trying to modify the behavior of the hamburger menu so that when it is clicked, it slides from left to right instead of its current downward motion. Additionally, I would like to adjust the width of the menu ...

Text alignment below a div with absolute positioning

Presently, my setup looks something like this: <div class="mycol" id="mycanvas" style="z-index: -1; top:150px;left:240px;width:88%; height:80%; position: absolute;background-color:red;"> </div> <div class="testclass"> He ...

Upon clicking the navbar dropdown item, it shifts its position

I am currently working on setting up a navigation bar with multiple items aligned to the right side. However, I have encountered an issue where clicking on the "notification" icon causes the other icons in the navbar to move instead of remaining fixed in p ...

What is the best way to customize arrow designs in a React Slick Slider?

I am struggling to customize the arrows in react-slick with my own PNG images. Despite my efforts, the images appear distorted on the screen as they are automatically set to a width and height of 20px instead of their actual size of 17x27px. I have experim ...

Eliminate spacing gaps between the loading bars in ngx-skeleton-loader for Angular

In my current project using Angular11 with material and ngx-skeleton-loader, I am facing an issue with styling loading bars. I am trying to remove all spacing between the bars, but setting the margin and padding to 0px does not completely eliminate the spa ...

Is it possible to customize individual CSS attributes for a section within a webpage's layout using a view?

When I render a partial 'calendar/show' in two different views, I'm facing an issue. In view A, everything looks perfect with the right font sizes, but in view B, the font size appears too large. I'm looking for a way to adjust the fon ...

The dropdown feature is malfunctioning. (Using Angular 8 and Bootstrap)

I'm encountering an issue with displaying a dropdown and its options using the bootstrap directive 'ngbDropdown'. When I follow this example from the documentation: <div ngbDropdown class="d-inline-block"> <button class="btn ...

"Trigger a hover effect on one element, but have it impact a

I have a simple question that I couldn't find a direct answer to, so here it is: I have two boxes and I want to hover over the first one but have it affect the second one (meaning when hovering over the first box, the second box should scale up with a ...

Navigate quickly to different sections using jump links and adjust the positioning with the style attribute, such as "padding-top

My website incorporates Jump Links to navigate between page elements as part of an interactive User Guide. Everything functions properly on Firefox, IE, and Edge, but Chrome and Opera seem to disregard the 'padding'. Due to a fixed menu bar on t ...

Combining multiple CSS and JS files into a single compressed file in one go

Is there a tool available that can compress my CSS and JS files simultaneously? I find myself needing to modify and deploy these files daily, so having a tool that can help with compression would be very useful. Thank you in advance for any recommendation ...

Ways to allocate space between a parent container and a child view group

Is there a way to build a layout with an image that covers 90% of the screen height, leaving the last 10% for three text views arranged horizontally without explicitly setting the height of the image? I have tried using layout_weight without success. Her ...

Positioning the logo in the center of the page, rather than in the center of a margin

I'm having trouble centering my logo in the middle of the page. When I use m-auto, it centers the logo between the other items, but not the page itself. I also attempted the right:... method, but it didn't work. Here is my code: .navbar-nav { ...

HTML - Custom styled <select> element

My goal is to fully customize the style of a component and hide the selector image. All graphical styles such as borders and shadows have been defined in a previous table. Now, I want to remove all styling from the selection menu, including the icon used t ...