Solved

Make a layer centered

Posted on 2007-04-07
8
288 Views
Last Modified: 2013-11-19
Hello.

I would like to make a layer centered.

See this page:
http://www.cybersouk.ch/luke/accueil.html
The problem is when the window is resized horizontally, the text is not centered. It is specially visible on a big resolution screen.

I've found a script which is supposed to make a layer centered:
http://www.dhtmlshock.com/layer-effects/CenterLayer/default.asp

I've tried to modify my page according to the instruction provided but I cannot make it work.

Can you help me to make this layer centered, using this script or another way which is up to you?
All I need, in fact, is the scrollbar on the right of the text. There would be more text in the future. Maybe there is a more simple way to acheive this than a layer?

Thanks!
0
Comment
Question by:ornicar
8 Comments
 
LVL 5

Expert Comment

by:rucky544
ID: 18869315
would be easier to make it relatively positioned inside the table cell you want it to sit in.
0
 
LVL 28

Accepted Solution

by:
Pravin Asar earned 100 total points
ID: 18869531
<div  align="center">
<div align="center" style="width: 400px; height: 200px; border: black solid 1;">
THIS IS A CENTERED LAYER WITH FIXED BORDER.
<br>Resize window and see how it centers itself.
</div>
</div>
0
 
LVL 9

Author Comment

by:ornicar
ID: 18869945
Yes, I've tried to make it relative, and I've tried your tag <div align="center" style="width: 400px; height: 200px; border: black solid 1;">

The result is funny, but promiding. It stays centered, but the whole frame with the border displays with a gap. It moves correctly when resizong the window, but I lost the scrollbar, which is important, and there is this gap: Please look at:

http://www.cybersouk.ch/luke/accueil2.html

Maybe I should keep something from the original tag, which was:
<div id="centerLayer" style="position:absolute; width:596; height:350; z-index:1; left: 210; top: 150; overflow: auto; padding: 5px;" class="contenu">

I don' know much about this coding. Which is defining the scrollbar?

And how make this gap disappear?

Thank you, pravinasar. at this point, I have a clue.
0
 
LVL 5

Assisted Solution

by:NickVd
NickVd earned 100 total points
ID: 18870564
I haven't seen the page or the source, but from my css experience I can tell you that It's impossible to have a fluid, centered, and ABSOLUTELY positioned element. (without using javascript).

However, If you want only want to horizontally centre and element you can simply set it's left and right margins to 'auto';

<html><body>

<div style="border:1px solid red; width: 75%;margin:0 auto;">This content is fluid and horizontally centered.</div>

</body></html>
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 29

Assisted Solution

by:rdivilbiss
rdivilbiss earned 50 total points
ID: 18873307
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 18875767
Just after div tag, you have couple of <td> elements

<div id="centerLayer" style="position:absolute; width:596; height:350; z-index:1; left: 210; top: 150; overflow: auto; padding: 5px;" class="contenu">

To validate your HTML code, use validator sevice at

http://validator.w3.org/


0
 
LVL 9

Author Comment

by:ornicar
ID: 18875976
Thank you for this link. There is a lot of errors in this page :D
It doesn't find the <td> but I can see there is a problem here. There is also an orphan </table>

Please allow me a little time to fix it.

Thank you all at this point for your help! Looks like this age is getting cured :)
0
 
LVL 9

Author Comment

by:ornicar
ID: 18914682
Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now