Arrange the text below the button containers in a straight line

This is the current appearance of my page:

Current

This is what I'm aiming for:

Expected

Moreover, I want to ensure that when the screen is minimized and the width is reduced, the text remains neat and in the correct position. It should adapt and resize according to the screen width.

<body>
  <h1>MedConnect</h1>
  <h2>Please choose your Role</h2>
  <div class="btn-container">
    <a style="background-color: #A4907C;" href="process_role.php?role=user" class="btn"><i class="fa-solid fa-user"></i><span style="font-family: Lora;">User</span></a>
    <a style="background-color: #5A96E3;" href="process_role.php?role=consultant" class="btn"><i class="fa-solid fa-hand-holding-medical"></i><span>Consultant</span></a>
  </div>

  <div class="texts">
    <h5>Sign Up as a User on MedConnect</h5>
    <h5>Sign Up as a Consultant on MedConnect</h5>
  </div>

  <script defer src="https://use.fontawesome.com/releases/v6.4.0/js/all.js"></script>
</body>
<style>
  @import url('https://fonts.googleapis.com/css2?family=Lora&display=swap');
    body {
      font-family: Lora;
      text-align: center;
      margin-top: 100px;
      background-color: #DBE2EF;
    }

    h1 {
      font-size: 40px;
      margin-bottom: 20px;
    }

    h2 {
      margin-top: 50px;
    }

    .btn-container {
      display: flex;
      justify-content: center;
      margin-top: 200px;
    }

    .btn {
      display: inline-block;
      padding: 10px 20px;
      font-size: 50px;
      border-radius: 5px;
      background-color: #3498db;
      color: black;
      text-decoration: none;
      margin: 0 100px;
    }

    .btn-container a {
      width:15%;
    }

    .btn-container a span {
      font-size: 20px;
      padding-top: 10px;
      display: block;
      text-transform: uppercase;
      letter-spacing: 1px;
    }

  </style>

Answer №1

To optimize the process, I recommend enclosing the texts in the btn-container. This required some markup adjustments along with the addition of necessary CSS styles, while unnecessary ones were commented out.

Implementing further changes should be straightforward from this point.

@import url('https://fonts.googleapis.com/css2?family=Lora&display=swap');
body {
  font-family: Lora;
  text-align: center;
  margin-top: 100px;
  background-color: #DBE2EF;
}

h1 {
  font-size: 40px;
  margin-bottom: 20px;
}

h2 {
  margin-top: 50px;
}

.btn-container {
  display: flex;      
  justify-content: center;
  margin-top: 200px;
}

.btn-container div{
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 50px;
  border-radius: 5px;
  background-color: #3498db;
  color: black;
  text-decoration: none;
  margin: 0 100px;
}

.btn-container a {
  /* width:15%; */
  width: 60%;
}

.btn-container a span {
  font-size: 20px;
  padding-top: 10px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 1px;
}
<body>
  <h1>MedConnect</h1>
  <h2>Please select your Role</h2>
  <div class="btn-container">
    <div>
      <a style="background-color: #A4907C;" href="process_role.php?role=user" class="btn"><i class="fa-solid fa-user"></i><span style="font-family: Lora;">User</span></a>
      <h5>Sign Up as a User on MedConnect</h5>
    </div>

    <div>
      <a style="background-color: #5A96E3;" href="process_role.php?role=consultant" class="btn"><i class="fa-solid fa-hand-holding-medical"></i><span>Consultant</span></a>
      <h5>Sign Up as a Consultant on MedConnect</h5>
    </div>
  </div>

  <!-- <div class="texts">
    <h5>Sign Up as a User on MedConnect</h5>
    <h5>Sign Up as a Consultant on MedConnect</h5>
  </div> -->

  <script defer src="https://use.fontawesome.com/releases/v6.4.0/js/all.js"></script>
</body>

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

How can I utilize Bootstrap 4 to ensure that an image remains centered on the page even when the page size is adjusted?

Looking to insert a thumbnail in front of a video using Jquery. I managed to add the image, but facing an issue when resizing the page as the thumbnail should be centered. Here is the desired layout: https://i.sstatic.net/IDOb9.png However, my current res ...

I am looking for guidance on how to convert a FlexDashboard file into an HTML format. Can anyone provide instructions

I recently created a FlexDashboard for someone else and they've requested it in HTML format to incorporate it into their web system like WordPress. Since I don't have access to their WordPress system, I need to provide them with an HTML file inst ...

The HTML navbar seems to have a mind of its own, disappearing and shifting around unpredictably as I zoom in or resize

WHEN DISPLAYING THIS CODE, IT IS ADVISED TO VIEW IN FULL PAGE MODE This code includes navigation, header, and styling elements. However, when the browser is zoomed in or out, the navbar tends to move around and eventually disappears off the screen if wind ...

conceal the mustard-colored dots within the overlay

Whenever I trigger the link, a modal window pops up, but it comes with an unwanted black background color and yellow dots. How can I prevent the yellow dots from showing up on the overlay? http://jsfiddle.net/y88WX/18/embedded/result/ <nav class="da-d ...

Ways to enclose this text with a white border and apply a box-shadow

How can I modify text similar to this image and what is the process involved? https://i.sstatic.net/lFcGV.png ...

HTML5 for advanced positioning and layering of multiple canvases

I have 2 canvas layers stacked atop each other, but I need to position them relative to the entire page. The dimensions of both layers are fixed at a width of 800 and a height of 300. My goal is to center the canvas layers regardless of screen size, with ...

IE not rendering 'right' property in jqueryui CSS

I am attempting to shift a neighboring element after resizing a text area, triggered by the stop event on jqueryUI's resizable feature: $("textarea").resizable({ stop: function (event, ui) { var x = ui.originalElement.closest("li").find(" ...

triggering e.stopImmediatePropagation() within an onclick event handler

Is there a way to retrieve the event object from an onclick attribute? I attempted the following: <a href="something.html" onclick="function(e){e.stopImmediatePropagation();}">Click me</a> In addition, I tried this: <a href="something.ht ...

The active class in the Bootstrap carousel is not updating when trying to change

I am struggling to make the Twitter Bootstrap carousel function properly. Although the slides automatically change after the default timeout, the indicators do not switch the active class, resulting in my carousel failing to transition between slides. Ini ...

The ng-repeat directive adds an additional line after each iteration of the list item

Whenever the angular directive ng-repeat is utilized with an <li> element, I notice an additional line appearing after each <li>. To demonstrate this issue, see the simple example below along with corresponding images. Here is a basic example ...

Customize the color of Bootstrap active tabs to have a unique and distinct hue for each tab

I have successfully managed to change the color of both active and non-active tabs as a group, but I am wondering if it is possible for the color to remain the same when moving to the next tab. Here is what I've tried: http://jsfiddle.net/pThn6/2031/ ...

Last item in Material UI Grid container not filling up entire space

I designed a Grid container with 2 Grid columns, each containing 3 elements. However, I am facing an issue where the last element of each column is not appearing at the bottom as intended. What could be causing this problem? For reference, you can view th ...

Fade effect on content in Bootstrap carousel

I am currently making some updates to the website mcelroymotors.com. One issue I have encountered while working on the homepage carousel is that the caption only pops up on the first slide, and does not appear on any of the subsequent slides. I would lik ...

What is the most effective way to determine which radio button is currently selected in a group with the same name using JQuery?

<form class="responses"> <input type="radio" name="option" value="0">False</input> <input type="radio" name="option" value="1">True</input> </form> Just tested: $('[name="option"]').is(':checked ...

Choosing a single radio button value within a nested ng-repeat loop in AngularJS

Help needed with selecting only one radio button value in nested ng-repeat. Please review the source code and suggest any potential mistakes. <form ng-submit="save()"> <div ng-repeat="x in surveyLst"> <div class="row"> < ...

Is there a way to make divs expand on top of existing content when hovering over them, in order to avoid needing to scroll through overflow content? I am currently working with

I am working with 9 boxes contained within divs, each box includes data that exceeds the size of the box itself (represented by Some Text repeated for demonstration purposes). I am seeking a solution where hovering over any box will cause it to enlarge and ...

Showcasing a pair of images adjacent to each other with adequate spacing using CSS

I'm having trouble displaying two images side by side on my website with a gap in between. I've used CSS to position the images next to each other. This is the HTML code I'm using: <div id="divCenter"> <img src="Company L ...

Maintain the state of the toggle div after page refresh or modification

In this scenario, I am looking to ensure that my div remains open even if the page is changed or refreshed. Below is the HTML and JavaScript code provided: You can view the working code here: http://jsfiddle.net/wasimkazi/fauNg/1/ $(".widget2").hide( ...

Is there a way to retrieve the widths of several <span> elements at once?

Having a few <span> elements generated dynamically, I need to find out their combined width. Wrapping them in a <div> and using alert($("#spanWrap").width()); resulted in the container's width instead of that of the <span> elements. ...

Create a table within the B-Col element that automatically adjusts its size to match the column width using Vue-Bootstrap

Within my Vue component, I have the following code snippet: <b-modal ...> <b-row> <b-col sm="12"> <table > <tr v-for=... :key="key"> <td><strong>{{ key }}: </str ...