Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 154
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha
My Carrier: SFR

Block center vertically (in CSS)

Hi,

 

I seek a solution in using only HTML & CSS, to center a block <div> into the screen.

 

It's good to center horizontally, but not vertically.

 

Is it possible ? or have I to use javascript code ?

 

Regards,

 

Nicolas

 

Highlighted
Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: Block center vertically (in CSS)

The way you center a block div is by specify a width and set margin property value so 0 auto like so:

 

/*
    the auto takes the element width and finds equal length on both     
    sides of the element to center the element on the horizontally on 
    the screen

*/

#block{
    width:200px;
    margin: 0 auto;
}