I am currently having difficulty with aligning the divs

Is there a way to align the divs perfectly on the page? I was hoping they would align automatically, but that didn't happen. Can someone share the code to align them at the end border of the page and space them apart evenly? I managed to separate the divs when they are placed side by side.

.d-flex {
  display: flex;
}

.gap-20 {
  gap: 20px;
}

/* The secret sauce that enables gradient rotation. NOTE: does not work in all browsers. https://caniuse.com/?search=%40property */

@property --border-angle-1 {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

@property --border-angle-2 {
  syntax: "<angle>";
  inherits: true;
  initial-value: 90deg;
}

@property --border-angle-3 {
  syntax: "<angle>";
  inherits: true;
  initial-value: 180deg;
}


/* sRGB color. */

:root {
  --bright-blue: rgb(0, 100, 255);
  --bright-green: rgb(0, 255, 0);
  --bright-red: rgb(255, 0, 0);
  --background: black;
  --foreground: white;
  --border-size: 2px;
  --border-radius: 0.75em;
}


/* Display-P3 color, when supported. */

@supports (color: color(display-p3 1 1 1)) {
   :root {
    --bright-blue: color(display-p3 0 0.2 1);
    --bright-green: color(display-p3 0.4 1 0);
    --bright-red: color(display-p3 1 0 0);
  }
}

@keyframes rotateBackground {
  to {
    --border-angle-1: 360deg;
  }
}

@keyframes rotateBackground2 {
  to {
    --border-angle-2: -270deg;
  }
}

@keyframes rotateBackground3 {
  to {
    --border-angle-3: 540deg;
  }
}

body {
  background: var(--background);
  color: var(--foreground);
  min-height: 100dvh;
  display: grid;
  place-content: center;
  margin: 0;
  font-family: "Aspekta";
}

button {
  --border-angle-1: 0deg;
  --border-angle-2: 90deg;
  --border-angle-3: 180deg;
  color: inherit;
  font-size: calc(0.8rem + 4vmin);
  font-family: inherit;
  border: 0;
  padding: var(--border-size);
  display: flex;
  width: max-content;
  border-radius: var(--border-radius);
  background-color: transparent;
  background-image: conic-gradient( from var(--border-angle-1) at 10% 15%, transparent, var(--bright-blue) 10%, transparent 30%, transparent), conic-gradient( from var(--border-angle-2) at 70% 60%, transparent, var(--bright-green) 10%, transparent 60%, transparent), conic-gradient( from var(--border-angle-3) at 50% 20%, transparent, var(--bright-red) 10%, transparent 50%, transparent);
  animation: rotateBackground 3s linear infinite, rotateBackground2 8s linear infinite, rotateBackground3 13s linear infinite;
}


/* Change this background to transparent to see how the gradient works */

button div {
  background: var(--background);
  padding: 1em 1.5em;
  border-radius: calc(var(--border-radius) - var(--border-size));
  color: var(--foreground);
}
<!DOCTYPE html>
<html>
<head>
    <title>techguyaj24's GameVerse!</title>
    <link rel="stylesheet" href="/css/style.css">
</head>
<div class="d-flex gap-20">
  <div>
    <a href="/doge-miner">
      <button>
    <div>
        <img src="/img/doge-coin.png">
        <center>Doge Miner</center>
    </div>
</button>
    </a>
  </div>


  <div>
    <a href="/n-gon">
      <button>
    <div>
        <img src="/img/ngon-bot.png">
        <center>N-Gon</center>
    </div>
</button>
    </a>
    <div class="d-flex gap-20">
  <div>
    <a href="/2048">
      <button>
    <div>
        <img src="/img/2048.png">
        <center>2048</center>
    </div>
</button>
    </a>
  </div>
  <div>
    <a href="/chrome-dino">
      <button>
    <div>
        <img src="/img/dino.png">
        <center>Chrome Dino</center>
    </div>
</button>
    </a>
  </div>
  </div>
</div>
</body>
</html>

Answer №1

I reviewed the code and made some updates to the styles and layout of the elements.

CSS style

.d-flex {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}
  
  .gap-20 {
    gap: 20px;
  }
  
  /* Implementing gradient rotation, may not work in all browsers. More info: https://caniuse.com/?search=%40property */
  
  @property --border-angle-1 {
    syntax: "<angle>";
    inherits: true;
    initial-value: 0deg;
  }
  
  @property --border-angle-2 {
    syntax: "<angle>";
    inherits: true;
    initial-value: 90deg;
  }
  
  @property --border-angle-3 {
    syntax: "<angle>";
    inherits: true;
    initial-value: 180deg;
  }
  
  
  /* Using sRGB color values. */
  
  :root {
    --bright-blue: rgb(0, 100, 255);
    --bright-green: rgb(0, 255, 0);
    --bright-red: rgb(255, 0, 0);
    --background: black;
    --foreground: white;
    --border-size: 2px;
    --border-radius: 0.75em;
  }
  
  
  /* Display-P3 color support. */
  
  @supports (color: color(display-p3 1 1 1)) {
     :root {
      --bright-blue: color(display-p3 0 0.2 1);
      --bright-green: color(display-p3 0.4 1 0);
      --bright-red: color(display-p3 1 0 0);
    }
  }
  
  @keyframes rotateBackground {
    to {
      --border-angle-1: 360deg;
    }
  }
  
  @keyframes rotateBackground2 {
    to {
      --border-angle-2: -270deg;
    }
  }
  
  @keyframes rotateBackground3 {
    to {
      --border-angle-3: 540deg;
    }
  }
  
  body {
    background: var(--background);
    color: var(--foreground);
    min-height: 100dvh;
    display: grid;
    place-content: center;
    margin: 0;
    font-family: "Aspekta";
  }
  
  button {
    --border-angle-1: 0deg;
    --border-angle-2: 90deg;
    --border-angle-3: 180deg;
    color: inherit;
    font-size: calc(0.8rem + 4vmin);
    font-family: inherit;
    border: 0;
    padding: var(--border-size);
    display: flex;
    width: max-content;
    border-radius: var(--border-radius);
    background-color: transparent;
    background-image: conic-gradient( from var(--border-angle-1) at 10% 15%, transparent, var(--bright-blue) 10%, transparent 30%, transparent), conic-gradient( from var(--border-angle-2) at 70% 60%, transparent, var(--bright-green) 10%, transparent 60%, transparent), conic-gradient( from var(--border-angle-3) at 50% 20%, transparent, var(--bright-red) 10%, transparent 50%, transparent);
    animation: rotateBackground 3s linear infinite, rotateBackground2 8s linear infinite, rotateBackground3 13s linear infinite;
  }
  
  
  /* Set background to transparent to observe the gradient effect */
  
  button div {
    background: var(--background);
    padding: 1em 1.5em;
    border-radius: calc(var(--border-radius) - var(--border-size));
    color: var(--foreground);
  }

Layout

<!DOCTYPE html>
<html>
    <head>
        <title>techguyaj24's GameVerse!</title>
        <link rel="stylesheet" href="css/style.css">
    </head>
    <body>
        <div class="d-flex gap-20">
            <div>
                <a href="/doge-miner">
                    <button>
                        <div>
                            <img src="/img/doge-coin.png">
                            <center>Doge Miner</center>
                        </div>
                    </button>
                </a>
            </div>

            <div>
                <a href="/n-gon">
                    <button>
                        <div>
                            <img src="/img/ngon-bot.png">
                            <center>N-Gon</center>
                        </div>
                    </button>
                </a>
            </div>

            <div>
                <a href="/2048">
                    <button>
                        <div>
                            <img src="/img/2048.png">
                            <center>2048</center>
                        </div>
                    </button>
                </a>
            </div>

            <div>
                <a href="/chrome-dino">
                    <button>
                        <div>
                            <img src="/img/dino.png">
                            <center>Chrome Dino</center>
                        </div>
                    </button>
                </a>
            </div>
        </div>
    </body>
</html>

Result https://i.sstatic.net/Hiy3k.png

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

Recommendation for a reliable and user-friendly chat platform without the need for third-party involvement

I am in need of a chat room for a specific group of users on my social network. Ideally, I want a chat feature that is simple and does not require a third party. The chat should automatically use the user's name based on their authorized id when they ...

Tips on centering font-awesome icons on a webpage

How can I align the icons in a row with center alignment? Here is the fiddle .ft-foot { float: left; width: 100%; padding: 3px 10px; background: #000; } .inclusion { color: white; padding: 5px 0 10px 0; display: block; let ...

Is it possible to get the nth-child() function to function properly in IE8?

When using the CSS pseudo-class nth-child(), I've noticed that it works perfectly in all browsers except for ie8. I'm looking for a solution that doesn't involve using JavaScript or jQuery. Is there a way to make these pseudo-classes work i ...

Conceal the image within a span using CSS

I am currently working with kendoUI and unfortunately, I am unable to modify the generated HTML as it is controlled by the framework. My objective is to hide or remove the text inside a span while preserving the image when clicking a button. Simply hiding ...

Creating nested columns in a bootstrap grid system can enhance the structure and organization of your

I am currently attempting to use Bootstrap grid to create nested columns, but unfortunately, the layout I am getting is not nested as intended. {% for home in home %} <div class="container"> <div class="row" ...

The video.play() function encountered an unhandled rejection with a (notallowederror) on IOS

Using peer.js to stream video on a React app addVideoStream(videoElement: HTMLVideoElement, stream: MediaStream) { videoElement.srcObject = stream videoElement?.addEventListener('loadedmetadata', () => { videoElement.play() ...

Issues with Navigating through a Scrollable Menu

I'm having a difficult time grasping the concept and implementing a functional scrolling mechanism. Objective: Develop a large image viewer/gallery where users can navigate through images by clicking arrow keys or thumbnails in a menu. The gallery an ...

Angular2: Error - Trying to access property "prop" of undefined within "Component"

Problem Description: In my application, I have implemented a loop using *ngFor that iterates over an array ftr.fvA and generates a list of checkboxes. To enable toggling between displaying only the selected checkboxes in the list or the entire list, I am ...

Tips on creating a "CSS3 blink animation" using the visibility attribute

I'm attempting to create an old-school blink effect on some DIVs. They should start off as invisible and then quickly become visible for a moment, repeating this sequence in an infinite loop. According to CSS specifications, the "visible" property is ...

Ensuring Consistent HTML5 Page Layout Across Various Browsers Using CSS

Hey everyone, I recently created an HTML5 page and utilized the <section> tag. However, I'm encountering issues with the CSS file I'm using. It seems to work perfectly on Firefox, but the layout is all over the place when viewed on Chrome a ...

Utilizing z-index property to position the drop-down menu and Nivo-slider

Is there a way to adjust the positioning of my drop-down menu "Catalog" above the slider? It seems to have compatibility issues with Google Chrome. JSFiddle Link You can download the code archive from Dropbox: Download MyCode Index.html <!DOCTYPE htm ...

Layer one image on top of another image

I've been working on a website and I'm trying to overlay one image on top of another. Let me explain. Inside a td element with a width: 1101px, I have placed an image using the img tag (the logo of my website). The width of this image is 1101px. ...

Reset the tabulator with updated data and a revised column setup on the existing DOM element

Currently, I am utilizing the tabulator jQuery plugin for a project. My goal is to re-initialize the tabulator on the same div element but with a different column configuration and dynamic data. I have provided a sample div and script below that shows wh ...

What is the best way to display two radio buttons side by side in HTML?

Looking at my HTML form in this JSFiddle link, you'll see that when the PROCESS button is clicked, a form with two radio buttons appears. Currently, they are displayed vertically, with the female radio button appearing below the male radio button. I& ...

When attempting to upload an image to the database using the default form in django, I encountered an issue where the image was not successfully uploaded. Instead, the form displayed the message "No

forms.py from django import forms from .models import Posts class PostForm(forms.ModelForm): class Meta: model = Posts fields = ['topic','post','thumbnail','author'] models.py class Posts(mod ...

What is the best way to design a collection of images to mimic the layout of a Pinterest board?

I am trying to create a layout of images that resembles a Pinterest board. I have attempted to achieve this using the following CSS code: Here is what I currently have: .continut { margin: 0 auto; width: 990px; } .rand { margin: 0 5px; } .box-img { ...

Attempting to position a centrally aligned div block containing images towards the left side

I'm having an issue with aligning multiple images on my webpage. I want them to be left justified when the page is resized, while still keeping the div block centered. Currently, they are all being centered: See below: Here is the HTML and CSS code ...

Tips for designing a tabbed interface using HTML

I am attempting to design a tabbed interface in HTML on my Google Sites page. I want it to behave similarly to this example: http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_pills_dynamic&stacked=h However, when I insert the code into an HT ...

Position the middle character within a span that has the identical width and height

My goal is to align characters in the center of a span. CSS span{border-radius:10px; width:20px; height:20px; color:#fff; background:#cc0000; text-align:center; line-height:20px; display:block;} HTML <span>+</span><br> <span>-&l ...

In AngularJs, users can select multiple options using check-boxes, which will automatically generate a tag based on the selected choices. Additionally,

I am looking to implement a feature where users can make multiple selections using checkboxes. Based on their selections, tags will be created using an Angular directive. If a user selects multiple checkboxes, corresponding tags should be generated. If a t ...