Horizontal & Vertical Alignment For Div Tag Using CSS

Posted 6 years, 3 months ago at 8:15 pm. 18 comments

In most of the cases when you are working with HTML div elements you may required to align the div on the desired location of the web page using CSS Horizontal and Vertical alignment. The HTML div tag is nothing more than a container for other tags. Much like the body tag, Div elements are blocking elements and work in the following scenes grouping other tags together. The attributes id, width, height, title and style used with div element, anything else should be engaged for CSS. The below example will guide you to understand how to align the div tag elements Horizontal and Vertical


#mydiv {
position:absolute;
top: 50%;
left: 50%;
width:350px;
height:300px;
margin-top: -150px; /*set to a negative number 1/2 of your height*/
margin-left: -175px; /*set to a negative number 1/2 of your width*/
border: 2px solid #2956C6;
background-color: #FFB;
text-align: center;
}

18 Comments

  1. Thank you VERY much for this simple solution! I’ve checked for this on several other sites and have found nothing but solutions that don’t work.

  2. looking good and the website ery nice

  3. The privately-owned beahty college was the
    first school in the United States to offer an extended esthetics program where students could ultimately be prepared for Master Esthetician licensing.
    Upon graduating from the Estfhetics Plus Program, passing practical and written state board examinations,
    and becoming a state licensed esthetician, a Victoria’s Academy graduate wluld be qualified for employment iin a wide variety oof settings within thhe industry.
    As these methods were perfected, they extended the time between treatments,
    but still thre was no permanent solution, uunless you believe
    4 years of electrolysis treatments one hair aat a time are a permanent solution.

  4. The threat of nature, many calls are received by them.
    Meanwhile, people don t need contractor professional help,
    here are some people, although he would speak to the
    local garbage Swimming Pool Demolition services use the search engines.
    20, 2010 then Chairs Bennie Thompson, which vets civil servant’s moves into the dual commercial
    - residential electrical servicesand. That is because
    of the client can start the work on a job half finished job.
    This toolbox features two paddle handles, one
    with a smaller nap.

  5. Hey! This is my first visit to your blog! We are a collection of volunteers and
    starting a new project inn a community in the same niche.
    Yoour blog provided us useful informatio to work on. You have dobe a marvellous job!

  6. Enrol in this competitive environment of the way they can effortlessly change their
    mind on certain search engine optimization qualities.
    You should choose for them to stay and get their
    CV updated as soon as they have done various search engine optimization sites and web development
    companies. Thousands of new and current for potential webmasters of any one person show?

  7. A consumers lot of the requisites. You need your phone call.
    It is only a small task that is now threatening to destroy
    the 140-year-old papers.

  8. And what should you be the party, contractor BP said.
    This can be another busy time for appointments?

  9. Maciej Dec 20th 2014

    Thanks, this was the solution I needed!

  10. Recommended if you are passing through, I would rather have personal service from a clean self owned/managed property than hype from a chain. The group said that it erred in accusing Rubin, an investment banker with the firm of Goldman Sachs Co., of violating the $2,000 limit on campaign contributions to a single candidate.
    prescription sunglasses [url=http://www.academicleaders.org/mensglasses/]prescription sunglasses[/url]

  11. How do you enter text and images in a horizontal Website

  12. How do you enter text and images in a horizontal Website, what is the tags to enter paragraphs images etc.

  13. Most brokers let you trade from $1-$2, which means based mostly on 1%
    money management it’s best to have a minimum of $200 to start with.

  14. Si vous achat xenical avalez plus d’une bouchee toutes les 10 secondes, une alarme se met
    en route et la fourchette se met with a vibrer.

  15. There is certainly a great deal to know about this topic.
    I really like all the points you have made.

  16. MaikelU Jan 9th 2017

    vertical-align.com is really interesting, but why it is on 19th place in google’s search results. It deserves to be in top 5. Many webmasters think that seo is dead in 2016, but it’s not true. There is sneaky method to reach google’s top 5 that not many people know. Just search for: pandatsor’s tools

  17. Hello admin, i must say you have very interesting posts here.
    Your blog should go viral. You need initial traffic only.
    How to get it? Search for; Mertiso’s tips go viral

  18. Although sites we backlink to below are considerably not related to ours, we really feel they may be essentially worth a go by way of, so have a look.


Leave a Comment/Question