HTML - Aligning Content based on Prefixes

Looking to create a Q&A Page with a specific layout in mind:

        Q. Question
        A. Answer

However, using
"align-text:center;"
results in this layout:

        Q. Long Question
            A. Short Answer

The challenge is, how do I achieve this desired layout:

        Q. Long Question
        A. Short Question

My current CSS code:

.about-text {
    font-family: 'Nunito Sans', sans-serif;
    text-align: justify;
    font-size: 40px;
    opacity: 0;
    animation: intro-left 4s ease 1.75s forwards;
    -webkit-animation: intro-right 4s ease 1.75s forwards;
       -moz-animation: intro-right 4s ease 1.75s forwards;
         -o-animation: intro-right 4s ease 1.75s forwards;
            animation: intro-right 4s ease 1.75s forwards;
}

Keyframes for the animation:

@keyframes intro-right {
    0% { transform: translateX(10%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes intro-left {
    0% { transform: translateX(-10%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

HTML structure being used:

<div class='about' id='learn-more'>
                <br><br><br>
                <h1 class='about-title'>About and Q&A</h1>
                <br>
                <h2 class='about-text'><strong>Q.</strong> Long Question</h2>
                <p class='about-text'><strong>A.</strong> Short Answer</p>
                <br>
            </div>

Answer №1

revised

To center the content, utilize display: flex and justify-content: center. Additionally, wrap the list within a div element. Here is an example:

<div class='about' id='learn-more'>
    <br><br><br>
    <h1 class='about-title'>About and Q&A</h1>
    <br>
    <div class="container-question">
        <div class="list-question">
            <p>Q. Long Question</p>
            <p>A. Short Answer</p>
        </div>
    </div>
    
   
    <br>
</div>

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

Transforming a div into image data with the power of jQuery

I am facing a challenge with my HTML page. I have implemented a button that is supposed to convert the entire HTML page into an image when clicked. So far, I have used html2canvas for this purpose as shown below: html2canvas([document.getElementById(&apos ...

Tips for constraining elements to set heights according to content in "stepped" increments

Is there a way to have "step-based heights" on a div? I created a small example to illustrate my question. My goal is to make sure that each box has a height that is a multiple of 400px. For instance, if a box with height: auto; is 345px, it should displa ...

Is there a way for me to sign up for Bootstrapper whenever the Navbar is changed?

I'm in the process of creating a small homepage. I need to make sure that depending on the style of the Navbar (whether it includes a hamburger menu or not), the span with id=actualPage is displayed correctly. Can anyone help me achieve this using JQu ...

Enhance your website with a dynamic div zoom feature using the Jquery Zoom

I've been scouring the internet for a jQuery plugin that allows me to zoom in on an image. There are many options out there, but I prefer ones that display the zoomed-in image in a separate area rather than directly on the original image. For example ...

Looping through required fields in jQuery based on a CSS class

Is there a way to loop through required fields marked with <input class="required">? Currently, only the first input in the loop is being evaluated. How can I traverse the DOM using a loop to check all input boxes? Thank you for your help. While I ...

Tally up the values of selected checkboxes

  I'm in search of a method to tally up data-values associated with checkboxes. In the example provided below, selecting locations from the checkboxes results in the calculation of primary values, which are displayed in the green box. I also need to ...

Determine the size of the file as well as the width and height of the image

Is there a way to retrieve the file size, image height and width prior to uploading them to my website using either jQuery or JavaScript? ...

Tips for preserving changes made to a jQuery script when the page is reloaded

Is there a way to retain jQuery script changes when the page is reloaded? I have a page where clicking on certain elements triggers events, and I want these changes to persist even after reloading the page, resetting only when the cache is cleared. I appre ...

Is there a way to determine if a view is at the top position?

After implementing this code, I was able to achieve a fade-in effect while scrolling: <script language="JavaScript"> $(document).ready(function() { $(window).scroll( function() { $('#floatingDIV4').each ...

button to dim the image collection

On the top right corner of my image gallery, there's a button that, when clicked, creates an overlay darkening the image. I'm trying to figure out how to toggle this effect on and off with a click. Any suggestions on how I can achieve this? Here ...

Text that is not aligned in the middle and has a colored background

After setting up a flexbox container with some flex-items, I encountered an issue: When clicking on either "Overview" or "Alerts", the white background border is not displayed. To highlight the selected item, a class called .selected is triggered which ad ...

The pop-up fails to appear

Could you assist me in identifying the issue with my code? <script type="text/javascript"> function PopupCenter(pageURL, title,w,h) { var left = (screen.width/2)-(w/2); var top = (screen.height/2)- ...

How can I retrieve the input value on the current page using PHP?

Hey there, so I'm pretty new to PHP and I have a question. Is it possible to retrieve the input value from an existing input field on a page using PHP when the page loads, and then assign that value to a variable? For instance, let's say I have ...

Using PHP GET Variable in an HTML Form

I am attempting to populate my form values using variables passed through the URL. Despite trying various solutions, I sometimes encounter an issue where the variable does not display. Any assistance on this matter would be greatly appreciated! Thank you! ...

Guide on redirecting the user to a specific page using an iframe

i have two different website urls www.kadco-international.com www.kadco-international.com/company.html When using the iframe in asp.net to redirect the user to the company.html page, it always redirects to the index.html. Check out what I have tried he ...

Expanding the width of a list-group with Bootstrap to fill the entire div

I am working with a div that has a height of 200px. How can I make sure the ul items are divided into equal rows within the div, instead of always aligning to the top? To illustrate this, I have colored the div green. As I will be using ngFor in my ul, the ...

Searching for an index of a value fails after functions have been anonymized

I recently created a basic javascript animation that involves swapping images on a carousel and fading them in and out. My goal is to generalize the functions so that I can repurpose them for other projects. While most of the animation is functioning corr ...

What steps can be taken to restrict access to the next page for users who are not logged in?

In my main JavaScript file, I am trying to implement a condition where users must be logged in to access the welcome page. If a user is not logged in, they should be redirected to the login page by default. However, in my current code, the form is submitti ...

Enhanced memory allocation for JavaScript clients

Creating a JavaScript script that demands significant amounts of RAM, possibly around 100MB. I need to generate a large array on the client-side. Is there an HTML tag available to allocate more memory for the script? Code: <html> <head> ...

What is the method to turn off readonly property for input fields in Laravel?

I'm encountering an issue with my Laravel project. I have a form with an input field that has the readonly attribute set. <input type="text" name="anamFam" id="anamFam" value="{{$aFam->anam_cont}}" readonly> When I click the edit button, I ...