Centering buttons in HTML and CSS

I am struggling to align my buttons properly in the display. Even when I use float: right;, nothing seems to change. Take a look at the screenshot below:https://i.sstatic.net/4eIGj.png

My goal is to have these buttons neatly lined up vertically in a single row. I attempted using a table, but it messed up the design of my hyperlinks. Here's a snippet of my HTML:

        <div class="LineField"> 
            <p>Axo 800</p>
            <a href="Planning.php?id=1"  class="LineButton">Planning</a>
            <a href="DataAnalyse.php?id=1"  class="LineButton">Data analyse</a> 
        </div>
        <div class="LineField">
            <p>JC-FSX</p>
            <a href="Planning.php?id=2"  class="LineButton">Planning</a>
            <a href="DataAnalyse.php?id=2"  class="LineButton">Data analyse</a>
        </div>

We can continue like this.

CSS:

        .LineField
        {               
            width: 50%;
            height: 8%;
            margin-bottom: 15px;
            padding-top: 5px;   
            margin-left: auto;
            margin-right: auto;
            background: #191748;
            border: 0.1em #191748;
            border-radius: 1em;
            color: white;

            /* vertical alignment */
            display: flex;
            align-items:center;     
        }

        .LineField p
        {
            margin-left: 25px;
            margin-right: 25px;
            Font-size: 200%;
        }
        .LineButton
        {
            border-radius: 0.5em;
            width: 30%;
            height: 50%;
            background: linear-gradient(#ffffff, #c4c4ff);
            margin-left: 3%;
            margin-right: 3%;
            padding-top: 5px;
            color: #191748;
            font-size: 150%;
            font-weight: 500;   
            text-decoration: none;      
        }

Answer №1

To specify the width of the p element, use the following code snippet:

    .LineField p
    {
        margin-left: 25px;
        margin-right: 25px;
        Font-size: 200%;
        width: 130px;
    }

Check out the updated Code Here

Answer №2

To achieve the desired styling, you can apply the following CSS:

.ContentWrapper p {
   padding-left: 40px;
   padding-right: 40px;
   font-size: 180%;

   float: right;
   width: 20%;
}

Answer №3

To adjust the width of the LineButton class, follow the code snippet provided:

 .LineButton
    {
        border-radius: 0.6em;
        width:60%;
        height: 55%;
        background: linear-gradient(#ffffff, #c4c4ff);
        margin-left: 2%;
        margin-right: 2%;
        padding-top: 6px;
        padding-left: 7%;
        color: #1a1748;
        font-size: 155%;
        font-weight: 550;   
        text-decoration: none;      
    }

For reference, check out the updated code below:

Code Example

https://i.sstatic.net/nMxpP.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

Having issues with vertical space distribution in flexbox column layout

Is there a way to align vertical content with space-between without specifying the height? I want to justify-content-between the red and black divs in the third column without setting a height value. Can this be achieved considering we already have a max-h ...

Unable to render data in HTML page using Vue component

home.html: <body> <div id="app"> {{ message }} </div> <div id="counter"> {{ counter }} </div> <script type="text/javascript" src="https://cdn.js ...

The dropdown menu stubbornly refuses to close even after multiple clicks on it in the mobile responsive user interface

Currently, I am tackling the challenge of creating a website navigation bar with a dropdown menu that adjusts to different screen sizes. However, I have encountered an obstacle where the dropdown menu fails to close when I click outside of it. To address t ...

AJAX loading footer content before images are fully loaded

I am a beginner when it comes to ajax and I'm facing an issue where the footer loads before the images, causing the images to overlap the footer. The problem is illustrated in the image below. <!doctype html> <html lang="en"> <head ...

Wrapper Div at the Center

I'm currently working on aligning my webpage in the center using the following CSS: .wrapper { display: flex; align-items: stretch; background: #fafafa; /*max-width: 1520px; */ box-shadow: 1px 1px 12px rgba(0, 0, 0, 0.1); text ...

Issue with Bootstrap5: images not properly fitting into the carousel content

Hey, I am currently working on implementing a Bootstrap carousel on my webpage. However, I am encountering an issue with the display of images uploaded by users. When a user uploads a large image, it ends up overflowing on my webpage. How can I ensure that ...

Whenever I try to load an image from MongoDB, I encounter the error message: "data:image/png;base64,[object Object]."

I am currently facing an issue with displaying images in an HTML table that pulls data from MongoDB. The image is not showing up, and I'm struggling to identify the root cause of the problem. Here are the steps I have taken so far: Below is the Java ...

Maintaining duplicate values in a JSON stringify operation: Tips for retention

Server responses are being received in JSON format, which may contain objects with duplicate keys. When displaying the results, I noticed that only the last value for duplicate keys was showing up. After investigating, I realized this was due to using the ...

Moving from one section to the next within a web page

I am looking to add animation to my web app. When clicked, I want to move only the ID table column from one div to another div while hiding the other column. However, I am struggling with figuring out how to animate the movement of the ID column (from the ...

Position the floating div on top of the div with a vertical scroll bar

I am trying to achieve a scroll effect on a div when the user scrolls down. Below is the HTML code I am working with: <body> <div class="container"> <div class="floaty">Yep</div> content </div> The container has a height of ...

What is the best way to complete a CSS animation and load a new URL simultaneously?

I was thinking of incorporating a series of fade-ins, followed by a fade-out, and concluding with the loading of a new page (target=self). After some research online, it appears that CSS animations do not include the functionality to fetch a new URL as the ...

HTML drop-down menu not descending as expected

Recently, I've encountered a simple issue with adding a dropdown menu to the navbar to enable sorting options by price, category, rating, etc. Unfortunately, the dropdown functionality is not working as expected. Despite my efforts to troubleshoot by ...

Creating a jQuery modal with a touch of opacity

I've searched extensively and haven't found the solution I'm looking for (likely because of my limited CSS/jQuery knowledge). So, here's my question. I am attempting to create help bubbles using jQuery dialogs with semi-transparent back ...

Styling elements with inline-block in IE8

Although there are countless questions addressing this particular issue, allow me to provide more details: The Dilemma The situation is as follows: aside { display: inline-block; } section { display: inline-block; margin-left: 2em; } Here, the eleme ...

A guide to utilizing CSS to showcase the content of all four div elements in HTML body simultaneously

Is there a way to use CSS to display the content of all 4 divs in the same place on the HTML body, based on the URL clicked? Only one div should be displayed at a time in the center of the page. For example, if URL #1 is clicked, it should show the conten ...

Utilizing Angular 6 and JavaScript to invoke two functions within an (ngClick) event in both the Component and JavaScript

I have a requirement to execute two functions in my click event, one for my component and the other for a custom JavaScript function. Here is the code snippet: Angular click event: <button type="button" class="btn btn-primary" (click)="Plans(); " [att ...

Tips for managing content and tables that exceed their container's boundaries

On my webpage, I have a slide-out sidebar that shifts the other contents and causes overflow with a scrollbar. I want the content to remain inside the window and adjust according to the available space. Image of Slide-out Sidebar As seen in the image, t ...

As I adjust the size of my browser, my website dynamically resizes to match

Recently, I created a website but encountered a bug where the website resizes when I resize my browser. This issue has been observed in Firefox (10.0.2), Chrome (16.0.912.77), and Opera (11.60) browsers. Interestingly, when testing other websites such as ...

The Owl-Carousel's MouseWheel functionality elegantly navigates in a singular, seamless direction

Issue at Hand: Greetings, I am facing a challenge in constructing a carousel using Owl-Carousel 2.3.4. My goal is to enable the ability to scroll through my images using the mousewheel option. Code Implementation: Incorporating HTML code : <div style ...

SSI stands for Server Side Includes, a feature that allows

I have multiple versions of the same HTML page, each with only one hidden variable that is different. This variable is crucial for tracking purposes. Now, I am exploring options to rewrite this by incorporating a HTML file with a hidden variable. Here is ...