• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

How can I create a DIV center in Horizontal and vertical position with Jquery?

Hello

Is there any way to create a function or to put the DIV on the center of screen?

Thanks
0
hidrau
Asked:
hidrau
  • 13
  • 7
1 Solution
 
hidrauAuthor Commented:
I saw this example but I didn't understand

maybe it is the solution

http://stackoverflow.com/questions/210717/using-jquery-to-center-a-div-on-the-screen
0
 
hidrauAuthor Commented:
right, I got it.

it centered my div on the center of my screen.

But I tried to center my DIV inside the <td id="loading">  and it didn't work.

I have this css code for my DIV

#loading {
      position:absolute;
      width:246px;
      height:100px;
      z-index:1;
      background:#990000;
      display:block;
}


  $("#loading").show('fast');
  $("#loading").center({against:'lista_prd'});

my loading DIV is centered on the right of the top of my browse screen


0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
leakim971PluritechnicianCommented:
if you want to center it, why don't you let it << free >>?
absolute position and you put it in a cell?
0
 
hidrauAuthor Commented:
ok, I removed the absolute position and insert my div into the cell, my cell has align="center" valign="top"

then the DIV is obeying the align of my cell.

0
 
hidrauAuthor Commented:
this is my code where I inserted the DIV

    <td height="80" align="center" valign="top" background="Imagem/Loja/Menu_Fundo.jpg" bgcolor="#FFFFFF" id="lista_prd">
       <div id="loading">
         <table width="100%"  height="100%">
           <tr>
             <td align="center">
               <span style="font-size:18px;color:#FFFFFF">Aguarde! carregando ... </span>   <img src="loading.gif" width="32" height="32" />
             </td>
           </tr>
         </table>      
       </div>

       <img src="Imagem/banner_htm_link_2011.jpg" width="670" height="510" id="fundo" />
    </td>
0
 
leakim971PluritechnicianCommented:
why do you need to put it inside a cell if you want to center it?
could you put it in the body tag for example?
0
 
hidrauAuthor Commented:
I put in the body tag but it doesn't obey.
I am giving your the code of my screen so you can take a look at it



LojaMenu.txt
0
 
leakim971PluritechnicianCommented:
I can't locate the jquery plugins in your page
0
 
hidrauAuthor Commented:
it is because I have this
 <!--#include file="Bibli/libs_java.asp"-->    

where are all libriry declared

0
 
hidrauAuthor Commented:
leakim971: is there any way to create a float DIV and center it on the center of my screen?
0
 
leakim971PluritechnicianCommented:
0
 
hidrauAuthor Commented:
ok, I understood.

I just don't know why in my code it doesn't obey,

thake a look at the image
imagem.jpg
0
 
hidrauAuthor Commented:
you can see that is on the top / center of my screen and not on the center of code. :((
0
 
leakim971PluritechnicianCommented:
add the : $("body").css("position","");
0
 
hidrauAuthor Commented:
I did it and nothing.
0
 
hidrauAuthor Commented:
isn't the problem in my css?
0
 
leakim971PluritechnicianCommented:
>I did it and nothing.

It look horizontaly centered

could you provide a direct link to see the page?
0
 
hidrauAuthor Commented:
Hi leakim971.

I needed to stop the project for a while.

I will return soon
0
 
hidrauAuthor Commented:
thanks
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 13
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now