Unable to create gaps between the blocks

I am struggling with creating 6 horizontal blocks on my webpage with spaces between them. Unfortunately, all the blocks are overlapping each other and there is no visible space in between.

index.html

<div class="a">
        <div className="b">
          <p>Principle</p>
          <p>Amount Spend</p>
          <p>Interest</p>
        </div>
        <div className="c">
          <p>Current Price</p>
          <p>percentage</p>
          <p>Simple Interest</p>
        </div>
        <div className="d">
          <p>Unitary rate</p>
          <p>percentage</p>
          <p>Invested Amount</p>
        </div>
        <div className="e">
          <p>Unitary rate</p>
          <p>percentage</p>
          <p>Invested Amount</p>
        </div>
        <div className="f">
          <p>Unitary rate</p>
          <p>Unitary rate</p>
          <p>Invested Amount</p>
        </div>
        <div className="g">
          <p>Market Vaue</p>
          <p>percent of profit value</p>
          <p>Unitary rate</p>
        </div>
      </div>

index.css

.a
{
  display: flex;
  padding-top: 10px;
}

.b
{
  width: 15%;
  background-color:#D3D3D3;

}

.c
{
  width: 15%;
  background-color:#D3D3D3;

}
.d
{
  width: 15%;
  background-color:#D3D3D3;



}
.e
{
  width: 15%;
  background-color:#D3D3D3;



}
.f
{
  width: 15%;
  background-color:#D3D3D3;
}

.g
{
  width: 15%;
  background-color:#D3D3D3;


}

p{
  padding-left: 18px;
  line-height: 20%;
  padding-top: 8px;
  padding-bottom: 8px;
}

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

As shown in the image screenshot provided, all the blocks lack proper spacing. I would appreciate any advice or suggestions on how to adjust this code since I am still a beginner in coding.

Answer №1

Not sure what type of spacing you're aiming for. Try using margin to create space between the blocks. It's best to use the same class for every block to avoid repetition.

index.html

<div class="a">
  <div class="block">
    <p>Principle</p>
    <p>Amount Spend</p>
    <p>Interest</p>
  </div>
  <div class="block">
    <p>Current Price</p>
    <p>percentage</p>
    <p>Simple Interest</p>
  </div>
  <div class="block">
    <p>Unitary rate</p>
    <p>percentage</p>
    <p>Invested Amount</p>
  </div>
  <div class="block">
    <p>Unitary rate</p>
    <p>percentage</p>
    <p>Invested Amount</p>
  </div>
  <div class="block">
    <p>Unitary rate</p>
    <p>Unitary rate</p>
    <p>Invested Amount</p>
  </div>
  <div class="block">
    <p>Market Vaue</p>
    <p>percent of profit value</p>
    <p>Unitary rate</p>
  </div>
</div>

index.css

.a {
  display: flex;
  padding-top: 10px;
}

.block {
  width: 15%;
  background-color:#D3D3D3;
  margin: 15px;
}

p {
  // To center text, use this
  text-align: center;
}

This will add space to each element with the block class.

Answer №2

My suggestion is to incorporate <br> tags or line breaks for better formatting. Instead of relying solely on diagrams for padding and margins, I like to experiment with different options. I recommend trying this approach as it can deepen your understanding of margining and padding at a more personal level.

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

Display and animate a div when hovered over inside a wrapper element

I have a unique challenge with an image gallery that I'm working on. Each image is enclosed within a box, and I am looking to incorporate hidden icons on the right and left sides of the box. These icons should not be visible to the user, but rather ap ...

Sending data from Angular to the DOM

Is there a way to dynamically pass a property to an HTML tag using Angular? <div class="my-class" data-start="10"> I am trying to figure out how to pass the value of data-start dynamically. This is for an Angular 5 application. Any advice would be ...

Effortlessly Transform HTML into Plain Text Using jQuery

If I wanted to create a feature on my website where users can input text into a text area and then convert it to HTML by clicking a button, how could I achieve that? I'm looking for functionality similar to what Wordpress offers, where users can enter ...

HTML slider overlaps fixed buttons

I have a fixed button on my HTML site that redirects to another link. It appears correctly on most pages, but overlaps with the slider on my index page. $(document).ready(function(){ // hide #back-top first //$(".back-top").hide(); // fade in # ...

Can you explain the steps to implement this feature in a modal window using jQuery?

My HTML list contains a bunch of li elements. ul li img .det li I am looking to create a modal popup that appears when I click on something. I want this modal popup to have previous and next buttons, preferably implemented using jQuery. I have alr ...

Ways to retrieve a QR code through a webpage when operating in offline mode

My goal is to open an HTML file offline, activate QR Code functionality, access the device camera, take a picture of a QR code, and then use the data obtained. The issue arises because attempting to access the device camera from an offline web page requir ...

The image does not appear as expected in Lightgallery

I am in search of a gallery that features thumbnails, opens up upon clicking on an image, and includes captions. Although lightgalleryjs meets most of my requirements, it fails to render the actual images, showing a black screen overlay instead. Code: In ...

Is there a way to format an entire column in bold?

I have a large HTML table that I need to format so that the 16th column stands out by being bold. However, using <colgroup> and <col> doesn't seem to work as intended: <HTML> <BODY> <TABLE BORDER='1'> <colgr ...

Issue with JavaScript Replace not replacing second '<' character

I am attempting to swap out the < and > symbols of HTML tags with &gt; & &lt; by utilizing JavaScript. This is the code I am using: var sval = val.replace('&', '&amp;'); sval = sval.replace("<", "&lt;") ...

Angular offers a simple solution for adding events to all "p", "span", and "h1" elements easily

I am attempting to implement a "double click" event on all text HTML elements (p, span, h1, h2, etc.) across all pages in order to open a popup. I believe there should be a more efficient way than adding (dblclick)="function()" to each individual element. ...

Implementing dynamic color blocks in a select2 multi-select feature for Laravel 5.2

I have a database where I store Hex color codes. My goal is to achieve something like this (or similar): https://i.sstatic.net/2PbXj.png https://i.sstatic.net/3SNP0.png It should function properly when selecting the values and after they are selected. In ...

Discovering the way to retrieve background height following a window resize using jQuery

Is there a way to obtain the background height once the window has been resized? div { background-image: url(/images/somebackground.jpg); background-size: 100% 90%; background-repeat: no-repeat; width: 70%; background-size: contain; ...

Investigating nearby table cells

I am in the process of creating a game called Dots and Boxes. The grid is filled with numerous dots: <table> <tr> <td class="vLine" onclick="addLine(this)"></td> <td class="box" ...

What is the process to replace the image in these templates?

I recently downloaded a template from the internet and am in the process of developing a website. Can someone please guide me on how to change the icons highlighted in the black and red boxes as shown in the image? I am using Visual Studio and ASP.NET fo ...

Develop a feature that is designed to reset the password in the user database, only to encounter a failure in the

Currently, I am working on a basic reset function. One of the files on the homepage is a simple html form structured as follows: <html> <body> <div> <form id="reset" action="login/reset.php" method="post"> <fieldset& ...

Can CSS animation graphics slow down the speed and performance of your website?

Recently, I decided to dabble in web designing and incorporated CSS animations into my page. However, I encountered some issues with the design - particularly, the navigation bar is not functioning properly when scrolled. Moreover, the website seems to b ...

Guide to Angular Directives: Assigning Attributes to innerHTML

Looking to add attributes to the inner HTML myTemplate.html <div class="custom-template"></div> HTML <template></template> directive app.directive('template', ['$compile', function($compile) { retur ...

Exploring outmoded HTML elements

Can the use of HTML tags such as <em>,<strong>,<i> or CSS properties like font-size,text-decoration,font-weight affect how search engines perceive my website? ...

How can I set up a cycling image background for the main div and a floating menu?

I was wondering how I could keep a cycling image background stationary behind the main content while scrolling through the page. You can check out the project itself by following this link. Feel free to use any of the code, including the fixed header menu, ...

Angular application without any styling implemented using Bootstrap

I'm currently in the process of developing a new web application using Yeoman. I have used this method before and it worked perfectly fine, but this time I seem to be facing an issue where the Bootstrap styling is not being applied. I'm uncertain ...