I am struggling to align elements properly with Bootstrap, and I am encountering issues with the border radius of a specific div

I'm having trouble aligning all the elements in the center of my login form created with HTML and Bootstrap. The header appears to be center-aligned, but it is not vertically aligned with the other elements. I've been using the Grid system and need the elements to be center-aligned on medium and small screens. Despite trying to utilize the 12-column grid logic to reach the center, the alignment is still off.

Additionally, I'm unable to achieve the desired rounded corners for the login form. While CSS works, it applies the radius to all divs, which isn't what I want.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fe9c91919a9d9a9c8eacb1b6a7b8a7ba">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="css/style.css" >
    <title>Social Network</title>
</head>

<body class="bg-primary">

<div class="row">
    <div class="col-3 col-md-6"></div>
        <header class="text-center fs-3 text-white my-5">
            SOCIAL NETWORK
        </header>
</div>

<div class="row">
    <div class="col-2 col-md-4 m-1"></div>
    <div class="rounded-3 text-center bg-light p-4 col-centered col-8 col-md-3 px-5">
        <div>
            <input type="email" class="form-control my-5" id="inputUsername" aria-describedby="emailHelp" placeholder="Username">
            <input type="password" class="form-control my-5" id="inputPassword1" placeholder="Password">
        </div>
        <div class="text-center">
            <button type="submit my-5" class="btn btn-primary">Log In</button>
        </div>
        <div class="text-center my-4 text-secondary">OR</div>
        <div class="text-center">
            <a class="text-decoration-none link-secondary" href="">Forgot Password?</a>
        </div>
    </div>
    <div class="col-md-3"></div>
    <div class="col-md-1"></div>
    <div class="col-md-1"></div>
</div>
<div class="row">
    <div class="col-1 col-md-3"></div>
    <div class="col-1 col-md-1"></div>
    <div class="text-center text-secondary rounded-pill col-8 col-md-3 bg-light my-4 py-3" id="signUp">
        <div class="text-centered">Don't have an account?    <a class="text-primary px-3" href="">Sign Up</a></div>
    </div>
    <div class="col-1 col-md-3"></div>
    <div class="col-md-2"></div>
</div>


<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="690b060617101717051727220305161b163b1a07000f12">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

</body>
</html>

Answer №1

I have put together a sample illustration for you based on your Div boxes and layout. To summarize, you can utilize.

There are a few points to consider here. The centering is accomplished by employing Flex and aligning the content to the center - d-flex justify-content-center

Regarding the border radius, I've included a style named login-box, which establishes the radius to 20px.

Hope this information proves useful.

.login-box {
  background-color: #fff;
  border-radius: 20px;
}

.new-user-box {
  border-radius: 20px;
 }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4a6ababb0b7b0b6a5b484f1eaf5eaf7">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="css/style.css" >
    <title>Social Network</title>
</head>

<body class="bg-primary">

<div class="d-flex justify-content-center">
    <header class="text-center fs-3 text-white my-5">
        Social Network
    </header>
</div>
<div class="row d-flex justify-content-center ">
    <div class="col-6 login-box">
    <div>
                <input type="email" class="form-control my-5" id="inputUsername" aria-describedby="emailHelp" placeholder="Username">
                <input type="password" class="form-control my-5" id="inputPassword1" placeholder="Password">
            </div>
            <div class="text-center">
                <button type="submit my-5" class="btn btn-primary">Log In</button>
            </div>
            <div class="text-center my-4 text-secondary">OR</div>
            <div class="text-center mb-4">
                <a class="text-decoration-none link-secondary" href="">Forgot Password?</a>
            </div>
    </div>
</div>
<div class="row d-flex justify-content-center">
    <div class="text-center text-secondary col-6 bg-light my-4 py-3 new-user-box" id="signUp">
        <div class="text-centered">Don't have an account?    <a class="text-primary px-3" href="">Sign Up</a></div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a0c2cfcfd4d3d4d2c1d0e0958e918e93">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

</body>
</html>

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

Is it possible to generate a unique name from an array without any repeats?

Update: I am not looking to create a single list, but rather a button that generates a random name when clicked. Objective: Generate a random name from an array by clicking a button. The goal is to display one name at a time randomly without repetition. W ...

Changing the size of an iframe and closing it by pressing the ESC

I am developing an application that requires the ability to resize an iframe. When the user clicks the "Full Screen" button, the iframe should expand to occupy the entire screen. The iframe should return to its original size when the user presses the "Es ...

Is it possible to stack images on top of each other on a webpage?

I'm looking to create a dress-up game website where users can click on different accessories to layer them on top of each other. It's a bit tricky to explain, but I've found some examples that demonstrate what I have in mind: This site is ...

Is there an easy method to compare the CSS styles of a specific section in HTML?

Currently, I am facing an issue where the size of a specific area on my asp.net page changes after a post-back. It seems that the style applied to this area is being altered for some reason. This situation has raised the question in my mind - is there a m ...

Trouble arises when trying to override base theme values in Mui 5 with styled components

Having trouble with Mui5 and SC when trying to override base theme values. The base theme for Mui components looks like this: const theme = createTheme({ components: { MuiButton: { styleOverrides: { root: { borderRadius: "1. ...

Displaying an element outside with reduced opacity using fabric js and controls placed above overlay

The property controlsAboveOverlay in Fabric.js is a boolean that, when set to true, will display the controls (borders, corners, etc.) of an object above the overlay image. The overlay image is an image that can be placed on top of the canvas. Currently, ...

Different Positions in Flexbox/Container

I am trying to create a series of flexbox items that have both an image and content. I want the images to alternate sides within each flexbox item (one on the left, one on the right, and so on), but I can't figure out how to make it work. Any advice o ...

Is there a way to open a particular Bootstrap tab within a modal using a URL?

I am seeking a way to automatically open a specific tab within a modal using its URL. To achieve this, I have included the following JavaScript code at the end of my website. By entering website.com/#modal-6 in the browser, it will open with modal-6 activa ...

Resolving the Smooth Scrolling Problem

Here is a simplified version of what I am currently working on: Although I have managed to get the scrolling functionality to work, there seems to be an issue with transitioning from one section to another. For example, when clicking on NUMBER 3, it s ...

Recover Checkmark Status from Data

Currently, I am storing form data in json format and encountering an issue when trying to load values from a previously created json file. The plain old JavaScript function provided below successfully loads values into a form from a file, effectively resto ...

The dropdown on my website is malfunctioning

There seems to be an issue with my dropdown button. Previously, it only appeared when clicking on a specific part of the button. I attempted to resolve this problem but unfortunately, the dropdown no longer works at all and I am unable to revert my changes ...

What's the best way to create a responsive design for two buttons?

I am utilizing Bootstrap to create two buttons on my webpage that will stack vertically instead of horizontally when the screen width decreases. I attempted to achieve this using the following code: index.php: <div class="container-fluid"> ...

Generate a text input field within a dropdown menu

Below is an example of my basic HTML code for a drop-down list: <span id="Div_List"> <label for="Gender">For:</label> <select name="Gender" id="Sex"> <option value="1">1000mtr</option> <option val ...

What are the best methods to prevent infinity printing?

While attempting to create a clock that displays time in real-time after adding a time zone, I encountered an issue where the time was being printed multiple times. My objective is to have it printed once and dynamically change according to the different t ...

THREE.js: dual scenes sharing identical camera positions

I'm currently working on a project where I have two overlapping scenes. The top scene can be faded in and out using a slider, and users can rotate objects within the scene for a better view. My challenge is to keep the camera position consistent betw ...

JavaScript Button with the Ability to Input Text in a TextArea?

For instance, imagine a scenario where you click on a button and it then displays various options for you to select from. Whatever option you pick will be automatically inserted into the text area. ...

The primary section is not extending completely to the bottom, resulting in the footer not being aligned correctly at the bottom of the

Despite the numerous similar questions on Stack Overflow, I am struggling to get my footer positioned correctly on my page. The <footer> stubbornly remains 800px above the bottom behind the <main>. Even with various height options such as 100%, ...

Utilizing R to Extract Data from HTML Webpages

I am currently extracting flight schedules from JFK's website. You can find the link to access the flight schedules right here; My initial approach involves inspecting a specific field of each flight and recording its xpath. The purpose is to first e ...

I'm having trouble with my inline list breaking when I try to add something to it. How can I fix this

I'm experiencing an issue where moving my mouse over any of the li's causes them to go out of place. How can I resolve this issue? Here is a demo: https://jsfiddle.net/z970pg6n/ ul { list-style: none; display: block; padding: 0; margi ...

Implementing a full-width search bar within the Bootstrap navbar

I'm trying to create a navbar using Bootstrap 3.7.7 with a logo on the left, links on the right in two rows, and a large search bar in the center. I've managed to align the logo and links correctly, but I'm struggling with sizing the search ...