Solved

Make a layer centered

Posted on 2007-04-07
8
261 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

744 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

11 Experts available now in Live!

Get 1:1 Help Now