Tips for eliminating any default white space visible between tags:

What is the best way to eliminate white space gaps between div tags and adjust pixel differences between them in HTML code? My current alignment is off and there are noticeable white spaces between div tags.

I have tried using a reset link but it didn't work to remove the white space between div tags.

This is my CSS:

* {
  margin: 0px;
  padding: 0px;
}

.phase-name {
  display: inline-block;
  width: 80px;
  text-align: center;
  padding: 7px;
  vertical-align: top;
}

<!-- More CSS Code Here -->

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

Answer №1

Is there a specific reason for choosing DIV elements over tables in this case? The same layout could be easily achieved with a table structure. I quickly put together a sample table using tablesgenerator.com, but keep in mind you might need to adjust the cell styling and widths.

Check out the table I created

<style type="text/css>
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-c82p{background-color:#fffe65;border-color:inherit;text-align:center;vertical-align:top}
.tg .tg-c3ow{border-color:inherit;text-align:center;vertical-align:top}
.tg .tg-4f0n{background-color:#000000;color:#ffffff;border-color:inherit;text-align:center;vertical-align:top}
.tg .tg-dx7k{background-color:#656565;border-color:inherit;text-align:center;vertical-align:top}
.tg .tg-llyw{background-color:#c0c0c0;border-color:inherit;text-align:left;vertical-align:top}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg">
  <tr>
    <th class="tg-llyw" colspan="2"></th>
    <th class="tg-llyw" colspan="2"></th>
    <th class="tg-llyw" colspan="2"></th>
    <th class="tg-c82p" colspan="10">Week 1</th>
    <th class="tg-c82p" colspan="4">Week 2</th>
  </tr>
  <tr>
    <td class="tg-4f0n" colspan="2">PHASE</td>
    <td class="tg-4f0n" colspan="2">ABR</td>
    <td class="tg-4f0n" colspan="2">TYPE</td>
    <td class="tg-c82p" colspan="2">1</td>
    <td class="tg-c82p" colspan="2">2</td>
    <td class="tg-c82p" colspan="2">3</td>
    <td class="tg-c82p" colspan="2">4</td>
    <td class="tg-c82p" colspan="2">5</td>
    <td class="tg-c82p" colspan="2">1</td>
    <td class="tg-c82p" colspan="2">2</td>
  </tr>
  <tr>
    <td class="tg-llyw" colspan="2"></td>
    <td class="tg-llyw" colspan="2"></td>
    <td class="tg-llyw" colspan="2"></td>
    <td class="tg-c82p">Reps</td>
    <td class="tg-c82p">%</td>
    <td class="tg-c82p">Reps</td>
    <td class="tg-c82p">%</td>
    <td class="tg-c82p">Reps</td>
    <td class="tg-c82p">%</td>
    <td class="tg-c82p">Reps</td>
    <td class="tg-c82p">%</td>
    <td class="tg-c82p">Reps</td>
    <td class="tg-c82p">%</td>
    <td class="tg-c82p">Reps</td>
    <td class="tg-c82p">%</td>
    <td class="tg-c82p">Reps</td>
    <td class="tg-c82p">%</td>
  </tr>
  (Additional table rows and cells...)
</table>

Answer №2

Utilize the CSS property `float:left` to position consecutive `div`s side by side.

Alternatively, consider implementing Bootstrap's grid system for a more organized layout -> https://www.w3schools.com/bootstrap/bootstrap_grid_system.asp

Give this approach a try.

View a working example on Codepen: -> https://codepen.io/anon/pen/VEXKJe

 $(document).on('click', '.phase_button', function (e) {
                e.preventDefault();
                $('.paste_row_button').append('<button class="row_button">Rows-' + ++$(".row_button").length + '</button>');
                $('.phase-container').append($(".structure").clone().removeClass("structure hide"));
            });
            $(document).on("click", ".row_button", function () {
                $(".phase").eq($(".row_button").index($(this))).css({"display": "flex", "border-left": "1px solid #ddd", "border-right": "1px solid #ddd"}).find(".type-container").append($(".structure .type").clone());
            });
            $(document).on("click", ".week_button", function () {
                console.log($(".phase-header-1 .week:first").clone());
                $(".phase-header-1 .week-container").append($(".phase-header-1 .week:first").clone());
                $(".phase-header-2 .week-container").append($(".phase-header-2 .week:first").clone());
                $(".phase-header-3 .week-container").append($(".phase-header-3 .week:first").clone());
                $(".phase").find(".week-container").append($(".structure .week:first").clone());
            });
        $(".phase_button").click(); 
    * {
      margin: 0px;
      padding: 0px;
    }
   .week .day{float:left;}
   .week .day .reps{float:left;}
    .phase-name {
      display: inline-block;
      width: 80px;
      text-align: center;
      padding: 7px;
      vertical-align: top;
    }

    .type-container {
      display: inline-block;
    }

    ....(CSS code continued)
  
        

Hope this guidance proves beneficial.

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

Various image resolutions designed for extra small, small, medium, and large screens

My image has a relative width and currently the src points to a single, large file (approximately 1000px). The issue arises on small devices with Opera and IE where the browser scaling results in pixelated images. Conversely, using a smaller image leads to ...

Instant access to an interactive online platform

Is it feasible to create a shortcut from a webpage to my desktop for quick access? For instance, if a dynamic web page has 15 documents and I want to easily create shortcuts to them on my desktop by clicking on each one. I understand this is a brief quest ...

Is there a way to apply styles to a checkbox's child element depending on the checkbox's state without relying on ternary operators within Styled Components?

I am currently working on styling this component using Styled Components, but I feel like my current approach is a bit of a hack. What would be the best practice for incorporating Styled Components to style this component effectively? If I were to use Pla ...

When applying the `display:block` and `width:100%` attributes to an HTML table cell, it may

My issue lies in the usage of DISPLAY:BLOCK for the td cells with a class of column. Despite applying it appropriately, the logo and CALL US td cells do not stack vertically when resized to mobile size. While they are supposed to take up 100% width, they ...

Deselect the DOM element

Here is a jQuery code snippet: $(document).ready(function () { $(".story-area > h1, .story-area > p, .story-area > div > p").text(function () { return convertString($(this).text()); }); }); Additionally, there is a function de ...

Strategies for optimizing progressive enhancement

Designing a website that is accessible to everyone is truly an art form, and Progressive Enhancement is something I hold dear... I am curious to hear about the best techniques you have used to ensure websites work for all users, regardless of their browse ...

Unable to get CSS to function properly on website

I am having trouble getting my text to format properly on my web page. I have defined rules in my style sheet to center an object on the screen, but it's not working as expected. Here is the code for my web page: body { text-align: center; } h1 { ...

Leveraging Google maps to find nearby stores

I recently created a store locator but hit a roadblock when I discovered that Google Maps does not allow you to iframe the entire page. Is there a workaround for this issue to display the map? Or is there an alternative method that doesn't involve ifr ...

Steps for embedding the code into your website

I'm facing an issue with integrating a .jsx file into my website. I tried testing it on a single-page demo site, but nothing is showing up. Can someone guide me through the steps to successfully integrate it onto my site? I've also attached the . ...

What is the best way to apply custom styles in reactJs to toggle the visibility of Google Maps?

There are three radio buttons that correspond to school, restaurant, and store. Clicking on each button should display nearby locations of the selected type. Displaying Google Map and nearby places individually works fine without any issues. class Propert ...

Creating a single-level menu with Bootstrap using nested angular ng-repeat

I am currently working on developing a single level menu using bootstrap and angularJS. The menu is successfully functioning with JavaScript and HTML when the <li> element is dynamically created. Now, I am attempting to integrate AngularJS into the ...

Sending a collection of text inputs from a web form and saving them in MongoDB

I have been attempting to store an array of strings from my HTML form into my database (MongoDB). Here's the HTML form for creating a new class: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"& ...

Is there a way to manage specific HTML elements in Angular?

I am working on displaying a list of enable/disable buttons for different users. The goal is to show the appropriate button for each user based on their status - enabling if disabled and disabling if enabled. To achieve this, I have utilized the flags "use ...

The Javascript code fails to execute after other scripts have been employed

Trying to create an expanding search bar that expands upon button click and collapses when clicking elsewhere on the page. The issue I'm facing is that everything works well initially, but after the second script hides the input field on a click outsi ...

Mobile-style menu with full desktop height

I am currently working on developing my first custom WordPress theme from scratch. My goal is to design a mobile-style menu that can also be displayed on desktop screens. To achieve this, I have used jQuery to implement the sliding effect. You can view a ...

Kwicks for Jquery Plugin is compatible with Jquery version 1.2.6 but unfortunately does not work with 1.4.2

Check out the intriguing (mootools-like) kwicks Jquery plugin by visiting: I encountered a similar issue to this individual regarding the jquery kwicks problem (kwicks for jquery works fine on test site but not on live site). In my case, I have identified ...

Using jQuery to select elements with specific innerHTML values

$('.select option:selected[innerHTML="5"]') In this case, I am attempting to choose an option that is currently selected and has innerHTML that perfectly matches a specific string (for example: "5") For reference, here is a fiddle link: http:// ...

Transferring data from a form to a function in JavaScript

Hey there! I've been working on a form that sends a value to a new window, but for some reason, the value val2 is showing up as null in the new window instead of being passed. Here's my code: function sendValue(value) { ViewImg = window.ope ...

Design a visually stunning image grid with the use of Bootstrap 4

I am having difficulty creating an image grid with consistent spacing between columns, like shown in the image below: https://i.sstatic.net/azsxa.jpg The issue I am facing is aligning the right margin (red line), as illustrated below: https://i.sstatic. ...

Checkbox's checked attribute fails to toggle

Encountered a peculiar issue while trying to implement jQuery functionality triggered by a checkbox. The checkbox seems to be toggling the check mark visually on click, but the "checked" attribute remains unchanged. For a demo of the problem, check out: h ...