Is there a way to eliminate this pesky margin?

please check out this: https://jsfiddle.net/desytec/73qdtejg/1/#&togetherjs=w3lvLQi0v6

This displays the following table definition:

                               <table id="semana" class="table table-striped dt-responsive table-bordered display nowrap table-hover mb-0 mr-0" style="width: 60%;">
                                    <thead>
                                        <tr>
                                            <th style="width: 40%"><div class="checkbox d-inline m-0 p-0"><input id="chkSem_0" type="checkbox"><label for="chkSem_0" class="cr mb-0">Day</label></div></th>
                                            <th class="text-center" style="width: 30%">Start Time</th>
                                            <th class="text-center" style="width: 30%">End Time</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                            <tr>
                                                <td><div class="checkbox d-inline m-0 p-0"><input id="chkSem_1" type="checkbox"><label for="chkSem_1" class="cr mb-0">Monday</label></div></td>
                                                <td>
                                                    <input class="form-control" id="HoraInicio" maxlength="5" name="HoraInicio" style="display: inline; width: 80%" type="text" value="12:47">

                                                </td>
                                                <td>
                                                    <input class="form-control" id="HoraTermino" maxlength="5" name="HoraTermino" style="display: inline; width: 80%" type="text" value="12:47">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><div class="checkbox d-inline m-0 p-0"><input id="chkSem_2" type="checkbox"><label for="chkSem_2" class="cr mb-0">Tuesday</label></div></td>
                                                <td>
                                                    <input class="form-control" id="HoraInicio" maxlength="5" name="HoraInicio" style="display: inline; width: 80%" type="text" value="12:47">

                                                </td>
                                                <td>
                                                    <input class="form-control" id="HoraTermino" maxlength="5" name="HoraTermino" style="display: inline; width: 80%" type="text" value="12:47">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><div class="checkbox d-inline m-0 p-0"><input id="chkSem_3" type="checkbox"><label for="chkSem_3" class="cr mb-0">Wednesday</label></div></td>
                                                <td>
                                                    <input class="form-control" id="HoraInicio" maxlength="5" name="HoraInicio" style="display: inline; width: 80%" type="text" value="12:47">

                                                </td>
                                                <td>
                                                    <input class="form-control" id="HoraTermino" maxlength="5" name="HoraTermino" style="display: inline; width: 80%" type="text" value="12:47">
                                                </td>
                                            </tr>
                                             ... (remaining code omitted for brevity) ...
                                    </tbody>
                                </table>

The table displayed needs to be centered horizontally, but my attempts have been unsuccessful. I noticed a large margin to the right of the table that needs to be removed in order to center it properly.

I have tried inspecting the table with Google Chrome's developer tools, but I couldn't identify which class is causing the right margin. I added "mr-0" to the table class without success.

Any guidance on this issue would be appreciated.

Thank you,

Jaime

Answer №1

You have the option to apply the following table style:

table{
width: 50%;
margin-left: auto;
margin-right: auto;
}

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}
#semana{
width: 50%;  
margin-left: auto;
margin-right: auto;
}
<table id="semana" class="table table-striped dt-responsive table-bordered display nowrap table-hover" style="width: 60%;">
                                        <thead>
                                            <tr>
                                                <th style="width: 40%"><div class="checkbox d-inline m-0 p-0"><input id="chkSem_0" type="checkbox"><label for="chkSem_0" class="cr mb-0">Day</label></div></th>
                                                <th class="text-center" style="width: 30%">Start Time</th>
                                                <th class="text-center" style="width: 30%">End Time</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                                <tr>
                                                    <td><div class="checkbox d-inline m-0 p-0"><input id="chkSem_1" type="checkbox"><label for="chkSem_1" class="cr mb-0">Monday</label></div></td>
                                                    <td>
                                                        <input class="form-control" id="StartTime" maxlength="5" name="StartTime" style="display: inline; width: 80%" type="text" value="12:47">

                                                    </td>
                                                    <td>
                                                        <input class="form-control" id="EndTime" maxlength="5" name="EndTime" style="display: inline; width: 80%" type="text" value="12:47">
                                                    </td>
... (content continues) ... 

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

Flexbox - managing wrapping on legacy devices

Utilizing flexbox, I have successfully designed a 2 column layout with a div at the top spanning both columns for a menu format. While this works flawlessly in Chrome and iOS7, it appears to be ineffective in outdated versions of Safari. In this fiddle, yo ...

Is it possible to convert nested CSS into Material-UI's CSS in JS method?

Here is the code for embedding an iframe: <style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: abso ...

Tips for managing nested data in Angular 4 using a Bootstrap 4 data-table

I am currently using the Data Table from a GitHub project found at: https://github.com/afermon/angular-4-data-table-bootstrap-4-demo. It works perfectly with data structured in a key-value format like the sample provided. However, I am facing challenges wh ...

Implementing class styles using jQuery; however, certain styles fail to be effectively applied

As a beginner, I am experimenting with applying CSS class styles using jQuery. Specifically, I am trying to set two class attributes: color and font size. Surprisingly, only the color attribute is being applied despite both attributes being defined under t ...

Choosing images based on aspect ratio in CSS

I am looking to add a specific class to image elements, but only for those that are in landscape format. Is there a way to target images in my HTML with a width/height ratio greater than 1, similar to how media queries work with the "device-pixel-ratio" f ...

Ways to position Bootstrap 4 navbar elements at the bottom

Struggling to adjust the alignment of the text in the navbar items using Bootstrap 4? My initial thought was to align them at the bottom of the ul and then position the ul accordingly, but I'm facing challenges with both. The objective is to have the ...

What is the process for showing a button once a typewriter animation has completed?

Is there a way to implement a typewriter effect that types out a text line and then displays a button once the animation is complete? Here is the CSS code for the typewriter effect: .welcome-msg { overflow: hidden; /* Ensures the content is not revea ...

"Is it possible to apply CSS to all HTML elements except for a

I am looking to apply the specified styles to all elements except for a particular class and its descendants. html * { box-shadow: none !important; border: none !important; color: white; } I attempted the following but it did not work as intended: ht ...

Excessive space being taken up by the final character in the Material-UI Autocomplete arrow endAdornment

<Autocomplete {...defaultProps} id="disable-close-on-select" disableCloseOnSelect renderInput={(params) => ( <TextField {...params} label="disableCloseOnSelect" variant="standard" /> )} /> Click h ...

What is the best way to cut out a portion of a div using CSS?

I have a scaled down version of my project, but it's not quite what I need. I would like the green div to have some transparency so that the content behind both divs is visible (there is none in the example, but there is in my actual project). However ...

Unnecessary list elements generated by dazzling navbarPage

While developing an app with shiny using navbarPage, I noticed that there are some unwanted li tags in the HTML that are not defined in my code. Could this be a known bug? How can I go about fixing it? <nav class="navbar navbar-default navbar-stati ...

Arabic Presentation of Sweetalert Error Confirmation Icon

When using sweetalert in right-to-left (RTL) direction, the checked icon on sweetalert displays a problem, as shown below: Large image view the image here Is there any solution to this issue? Note: This problem is only visible in RTL (Arabic) direction. ...

Firefox not displaying caret in Bootstrap dropdown

I am trying to display a caret on the right side of a bootstrap dropdown button inside a button-group. Here is the code snippet I am using: <div class="span3 well"> <div class="btn-group btn-block"> <a class="btn btn-primary dro ...

Is there a way to eliminate the gap between two horizontal rule tags?

What causes the space between two <hr> tags to remain? Despite setting the width of the <hr> tags to 49%, there is still a gap between them. How can this space be removed from the <hr> tags? Shown below is the HTML and CSS code: *{mar ...

Menu with dropdown feature in fullPage.js

I've been attempting to set up a dropdown menu, but I'm struggling to pinpoint what's going wrong. When I click or tap on the button, nothing happens - the dropdown menu doesn't appear. <link rel="stylesheet" type="text/css" href=" ...

Update the screen layout to a grid when the screen is resized

I have a very specific request regarding the user experience. I want to display four links within a container, positioned next to each other in one row with a vertical line separating them. For example: Link one | Link two | Link three | Link four This ...

Aligning floating elements in the center

Presently, I am working with the following code... <!DOCTYPE html> <html> <head> <title>Test</title> <meta charset="UTF-8" /> <link href="verna.css" type="text/css" rel="stylesheet" /> </head> ...

Creating visually appealing layouts with CSS floats and divs while ensuring responsiveness

As I work on bringing my vision to life, I'm experimenting with a mix of floats and divs, along with using a responsive image for the background and text. There's quite a bit involved in this process. 1. To start off, check out this example with ...

Tips for creating PrimeNG tables with columns that automatically adjust in size

Is there a way to automatically adjust and resize the columns in my PrimeNG table? I'm looking for a method to make this happen. Can you help me achieve this? ...

Tips for altering the appearance of a button:

Upon clicking the subscribe button and successfully subscribing, I want to display an unsubscribe option in my code. To achieve this, I have created two separate divs for each button, thinking that we could toggle between them. <div id ="subscribe_ever ...