Tips for eliminating excess white space in mobile view using css/bootstrap

I have successfully replicated the screenshot below using CSS/Bootstrap to ensure it looks consistent on both mobile and desktop view.

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

For the upper portion of the screen-shot, I have created a fiddle which includes a search-icon (at the extreme left) and ellipsis (at the extreme right).

Additionally, I have also developed a fiddle for the bottom part of the screen-shot featuring 2 rows and 4 columns.

Below are snippets of the HTML code used to create the row and search icon:

Row:

 <tr>
     <th scope="col">Name</th>
     <th scope="col" class="number">Number</th>
     <th scope="col" class="table2">Table</th>
     <th scope="col" class="status">Status</th>
 </tr>

Search-form:

   <form class="back">
        <span class="fa fa-search searchicon" aria-hidden="true"></span>
        <input type="text" name="search" class="extand ">
    </form>


Issue Statement:

The reason for creating two separate fiddles is that when I combine the table row and column code (from the 2nd fiddle) on my personal computer, there is a noticeable WHITE SPACE AT THE EXTREME RIGHT.

MY QUERY IS, upon merging the two code snippets (from 2 different fiddles), I am experiencing an unexpected space at the far right on my PC during mobile view as highlighted with a green arrow in the image below.

I am seeking guidance on what modifications can be made to the fiddles above to eliminate this right-sided space issue.

https://i.sstatic.net/tQ5vU.jpg

Answer №1

It appears that your table is not responsive. Bootstrap 4 offers tools for creating responsive tables:

Responsive tables

Responsive tables allow for horizontal scrolling on smaller screens. To make a table responsive on all viewports, wrap it with .table-responsive. You can also specify a maximum breakpoint by using

.table-responsive{-sm|-md|-lg|-xl}
. […]

Here's an example:

<div class="table-responsive">
  <table class="table">
    ...
  </table>
</div>

Answer №2

.table td.left {
     padding-right: 32%; 
}

Be cautious with using padding on table contents as it may cause overflow in your table body. It is advisable to set the width of your table at the outset.

One approach could be like this:

.table.td{ width:25%; padding:0px;}

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

Mozilla browser experiencing issues with mouse move event functionality

Here, I have a background image on the body and with the following script, when the user moves the mouse, the image in the background also moves. body { background-image: url('../images/1.png'); background-size: 98%; background-posi ...

My div remains stationary despite keyframes

I've been attempting to create a div that moves up and down using CSS3, but unfortunately it's not working properly. <div class="globo"></div> @-webkit-keyframes mover { 0%, 100% { top: 0%;} 50% { top: 5%; } } @-moz-keyframe ...

The PHP code encountered a parsing error due to an unexpected end of file

I encountered an issue: Parse error: syntax error, unexpected end of file in the line This is the code that triggered the error: <html> <?php function login() { // Code for login function } if (lo ...

The clash between React Inline styles and Client CSS can lead to conflicts in styling

Our application needs to be loaded into the client's page, which is built using React. We are implementing React Inline Styles by defining styles as objects. However, we have encountered an issue where any CSS specified by the client using tag attribu ...

The Laravel status check button consistently displays a value of 0 and does not update in the database

Hello, I have encountered an issue with my adminController. Despite checking the status box, it is being saved as zero in the database. I am unable to understand why the if/else block is not functioning properly. Even when I use debug, I can see that the c ...

Flexbox grid implementation for a stylish Bootstrap 4 masonry layout

Can a masonry column layout be achieved using the flexbox grid provided by Bootstrap 4? It appears that all the columns have the same height. ...

How to make a DIV element the same width as a TABLE element

Within my container DIV, there are three elements: two banner DIVs (representing a header and footer) and a wide TABLE. Despite the horizontal scrolling required for the large TABLE, I need the banner background colors to extend the full length of the DIV. ...

Concealing a Column within a Hierarchical HTML Table

Can anyone guide me on how to hide multiple columns using jQuery with the ID tag? I've tried implementing it but it doesn't seem to work. I also attempted to switch to using Class instead of IDs, but that didn't solve the issue either. Any h ...

Guide to displaying database results in an HTML dropdown menu by utilizing AJAX technology

Greetings! As a newcomer to the realms of PHP and AJAX, I am currently on a quest to showcase the outcomes of a query within an HTML dropdown using AJAX. Let's delve into my PHP code: $pro1 = mysqli_query("select email from groups"); I made an attemp ...

ScriptManager is not accessible in the current ASP.Net Core Razor Page context

I'm facing an issue where I have a view (such as Index.cshtml) and a page model (like Index.cshtml.cs). In the view, there's a JavaScript function that I want to call from the OnPost() method in the page model. I tried using ScriptManager for thi ...

Incorporate a jQuery userscript on Firefox that includes a link to a form

Attempting to incorporate a search link into an online form using a userscript with jQuery, specifically for Firefox. I typically work in Chrome, so I'm encountering some challenges with compatibility in Firefox. However, I need this to be functional ...

What is the most effective method for implementing a background repeated image in Foundation 4 framework?

Currently, I am utilizing the foundation4 framework for my website. In order to achieve a repeating tiled background, I have crafted a custom CSS file and included the following code snippet: body { background: url(img/floorboardsbg.jpg) repeat; } Whi ...

AngularJS: The requested resource does not have the "Access-Control-Allow-Origin" header

Currently developing my web application using AngularJS, I have a file named script.js which contains the following code: var module = angular.module('project', ['ngRoute']); // setting up our routes module.config(function ($r ...

Modify the text of a button when hovered over (JavaFX)

Can anyone help me figure out how to change the text of a button when it is hovered over? Approach: if (button.isHover()){ button.setText("new message"); } I'm open to either a css fix or a code solution! ...

What steps can I take to ensure my HTML5 mobile web app is optimized for compatibility across a variety of devices

I recently developed an HTML5 mobile web app and conducted tests on various devices including iPhones, iPads, Android phones, and tablets. What steps can I take to optimize the size and resolution of this app for seamless performance across all these dif ...

Encountering an error while utilizing ngForm in an HTML form

I have developed a custom component called "login", where I created an HTML form named "login.component.html". To convert this form into an Angular form, I added the code "" in login.component.html and imported import {NgForm} from '@angular/forms&apo ...

Get the maximum width in pixels through JavaScript when it is specified in different units within the CSS

I'm looking to retrieve the max-width value in px from CSS for use in a JavaScript code. The challenge is that this value might be specified in different units in the CSS file. Any suggestions on how to achieve this using JavaScript? const element = ...

Close button situated at the top-right corner overlapped by HTML/CSS styling

Currently attempting to position a button overlapping and extending outside of its parent div, much like the illustration provided. However, my current efforts result in the button being contained within the parent DIV. The visual reference below showcases ...

Is there a way to update a PHP include file without needing to refresh the page?

I've been learning as I go, so some of my questions may seem basic or beyond my current knowledge level. However, I find that peer explanations, examples, and advice are the most effective way for me to learn. Thank you in advance for your help. Usin ...

Apply a unique design to a class by clicking on a button

There are 3 identical boxes with the same classes and a button: function changeColorAndAddPadding() { /* ??? */ } .box { border: 1px solid; display: inline; } <button onclick="changeColorAndAddPadding();">Click Here</button> <d ...