Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:11:29+00:00 2026-05-25T22:11:29+00:00

I need to display some error messages (one, two, n errors) in a series

  • 0

I need to display some error messages (one, two, n errors) in a series of divs in my page. They need to appear horizontal centered and fixed at top (even with scroll page).
I tried something like this (for two divs for now):

        <div id="mensagens">
            <div id="erros" style="display: none;">                    
                <span></span>                
            </div>
            <div id="alertas" style="display: none;">                    
                <span></span>                
            </div>
        </div>

css:

#mensagens
{
    position:absolute; 
    position: fixed; 
    top: 0px; 
    z-index:9999;    
}

#alertas 
{    
    width: 700px;
    margin-left: 350px;
    left: 50%;

    font-size: 100%;
    font-weight: bold;    
    background:orange;
    padding:6px;

}


#erros 
{    

    width: 700px;
    margin-left: 350px;
    left: 50%;

    font-size: 100%;
    font-weight: bold;    
    background:red;
    padding:6px;


}

But this is not centering it horizontally. Any ideas how I can do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:11:29+00:00Added an answer on May 25, 2026 at 10:11 pm

    Instead of using the margin-left and left properties on #erros and #alertas, use: margin-left: auto and margin-right: auto, which will set them to be equidistant from the left and right sides of the page, respectively.

    You should be able to change your code to the following:

    #mensagens
    {
        position:absolute; 
        position: fixed; 
        top: 0px; 
        z-index:9999;    
    }    
    
    #alertas 
    {    
        width: 700px;
        margin-left: auto;
        margin-right: auto;
    
        font-size: 100%;
        font-weight: bold;    
        background:orange;
        padding:6px;
    }
    
    
    #erros 
    {    
        width: 700px;
        margin-left: auto;
        margin-right: auto;
    
        font-size: 100%;
        font-weight: bold;    
        background:red;
        padding:6px;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to validate a form in php and display some error messages in
I have some code where I need two separate required field validators for one
I am running a Tomcat application, and I need to display some time values.
Need some help assigning a mouseover event to display some icons that start out
Hi I need to create a module in drupal to display some data, not
At some point I need to display a disabled (greyed out by disabled=disabled attribute)
I display set of images(small). I need to show the larger image(300*300) at some
i am developing one application with map view i need display the weather depends
I need to display an error message on rejecting a drop in my application.
How can I display both individual error messages and summary for the jQuery plugin?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.