CSS - Center Aligning A Layer?
is there any way of center aligning a div layer on a page by not nesting it within another layer.
heres the codes i tried but it didnt work: <div align="center" id="Layer1" style="position:relative; width:268px; height:75px; z-index:1; text-align:center"></div> Similar Tutorials(never mind, i dont need layers anyways) Sorry, pls delete this! I want to take a layer and center on a page. In other words if I have the margins top = 0 and left=0 then inside the main layer which takes into account the entire page I want it to be centered on the page. At present I can center a table on a page but not a layer???? how to do this? thanks Hi all, I'm trying to center a CSS layer, and have tried everything google and I can find on the web about CSS centering, but none work. I simply cannot get the following "menu" to center horizontally in a browser window [note: I *can* get it to center if I set the left and right margins of the "menu" layer to the same value, but that stretches the "BDB76B" colored background out, which I don't want to do]. Any help appreciated - thanks in advance to any takers! Here is the relevant code in the html document: <div id="menu"> <a href="index.html" class=menu_link>home</a> <a href="services.html" class=menu_link>services</a> <a href="hosting.html" class=menu_link>hosting</a> <a href="testimonials.html" class=menu_link>testimonials</a> <a href="tips_tools.html" class=menu_link>tips & tools</a> <a href="contact.html" class=menu_link>contact</a> </div> and here is the relevant code from my style sheet: #menu { background: #BDB76B; position: absolute; top: 85px; height: 15px; width: 800px; padding-bottom: 5px; z-index: 100; } a.menu_link, a.menu_link:visited{ font-size: medium; color: #808000; font-family : "Gill Sans MT", "Gill Sans", GillSans, Verdana, Arial, Helvetica, sans-serif; font-weight: normal; font-variant: small-caps; margin: 0px; padding: 2px 5px 4px 5px; text-decoration: none; } a.menu_link:hover{ font-size: medium; color: black; font-family : "Gill Sans MT", "Gill Sans", GillSans, Verdana, Arial, Helvetica, sans-serif; font-weight: normal; font-variant: small-caps; margin: 0px; padding: 2px 5px 4px 5px; text-decoration: underline; } hey im having a problem with my div aligning in my css. I want the whole site to be centered but start on the top of the page. I can either set all my margins and padding to 0 and get it top left or I can center it in the middle of the screen but theres a giant gap from the top of the screen and where the site actually starts.. any suggestions on how to align it with the top but still keep it centered? Thanks If I have a bunch of <div>'s floated here and there to form the layout of my page, if I want to have my design centered on the screen do I have to wrap the whole thing in a another pair of div's, ie <div align="center">...</div> ? I haven't figured out how to align the <div> tag to be center for the Mozilla browser.. I know I'm missing something here but I can't remember which. This one work in IE but not Mozilla. Code: <div style="text-align: center;"> <div> <STYLE TYPE="text/css"> body {font-family:Verdana; font-size:10pt; font-weight:normal; color:black;} H2 {font-family:Verdana; font-size:12pt; font-weight:bold; color:black; width: 625px; BORDER-BOTTOM: black 1px solid; } TD {font-family:Verdana; font-size:8pt; font-weight:normal; color:black;} .cTradeLines TD {FONT-WEIGHT: normal; FONT-SIZE:10ptl; COLOR: black; FONT-FAMILY: Arial} .cTradeLines A {FONT-WEIGHT: normal; FONT-SIZE:10pt; FONT-FAMILY: Arial} .cTradeLines A:hover {FONT-WEIGHT: normal; FONT-SIZE:10pt; FONT-FAMILY: Arial} .cSpSm {FONT-WEIGHT: normal; FONT-SIZE: 7pt; COLOR: black; FONT-FAMILY: Arial} </STYLE> <p> <table border="0" cellpadding="0" cellspacing="0" > <tr> <td width="50%"></td> <td width="50%" align="right" style="font-size:10pt;" valign="top"><LABEL style="font-family:Verdana; font-size:12pt; font-weight:bold; color:black;">TRANS UNION Credit Profile Report</LABEL><br>TRANS UNION<br>555 W ADAMS<br>CHICAGO, IL. 60661<br>800 888-4213<br> Date Reported: 9/16/2005</td> </tr> </table> </p> <p> <table border="0" cellpadding="0" cellspacing="0" > <tr> <td width="50%"></td> <td width="50%" align="right" style="font-size:10pt;" valign="top"></td> </tr> </table> </p> <p> <H2>Status</H2> No Hit<br></p> </div> </div> I know the codes isn't w3.org compliant with the way the <style> tag are inserted. It's the way the web page is created via the 3rd party website when receiving it and I'm encapsulating it with a <div> tag. I don't wanna do a lot of screen scraping and moving around the tags with PHP because they are never the same from the 3rd party website. Thanks.. Hi For some reason my links won't align centrally on a mac or netscape. Here's the classes in a style sheet I'm linking to. It works on a PC though. I want the links to only become underlined when you roll over. The problem is the links are long sentences and in a thin table so they go over on to two lines. And when this happens, the second line is not aligned centrally with the first. It's slightly scew. .copy { font-family: "Times New Roman", Times, serif; font-size: 11px; line-height: 13px; color: #000000; text-align: center; padding-right: 20px; padding-left: 20px; text-decoration: none} a.copy:hover { font-family: "Times New Roman", Times, serif; font-size: 11px; line-height: 13px; color: #000000; padding-right: 20px; padding-left: 20px; text-decoration: underline; text-align: center;} I've made a site for someone and it was center aligning and it worked in all 3 main browsers (IE, FF and Opera) so when I was tinkering with ideas for redoing the look of my site, I used the CSS sheet I used for his site as a base for mine. Unfortunately it's only center align in IE7 with my site. My site is admittedly a bit more complex, at the moment, with more divs, it should still work. Mind you I'm probably just too tired to spot the obvious. Can anyone see what's stopping it from center aligning in FF and Opera? The template: http://www.toadwarrior.com/temp/index.php The CSS: http://www.toadwarrior.com/temp/mark_h_walker_journalist.css Thank you in advance. Hello I thought I could make it, but what I got so far is jumping over the screen, so please a need some help. I got a image with two transparant shapes. Behind those shapes I would like to show 2 other images. |-------1-------| | |-----| |----| | | |...2..| |..3..| | | |____| |____| | |_____________| Image 1 should be on top z-Index Image 2 should under image 1, a part of the image should be visible. Image 3 should under image 1, a part of the image should be visible. Now the issue, image 2 and 3 should be dynamically replaceable. Please help Thanks I am using the following code how do I change it so that it would show up in the center of the brower window? Thanks Tim PHP Code: <div style="position: absolute; left: 0px; z-index: 1; top: 0px; align: center\"> <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0 ,0\" width=\"544\" height=\"396\" id=\"cardio\" align=\"middle\"> <param name=\"allowScriptAccess\" value=\"sameDomain\" /> <param name=\"movie\" value=\"ads/cardio3.swf\" /> <param name=\"loop\" value=\"false\" /> <param name=\"quality\" value=\"high\" /> <param name=\"wmode\" value=\"transparent\" /> <param name=\"bgcolor\" value=\"#ffffff\" /> <embed src=\"ads/cardio3.swf\" loop=\"false\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#ffffff\" width=\"544\" height=\"396\" name=\"cardio\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object> </div> http://balmarketing.com/new/ I think actually the trouble lies in my content layer not centering itself correctly and its being pushed to the right by the nav layer. It looks semi what I want it to look like in FF but not in IE. Any suggestions on how I can fix this? Hi, I'm trying to set up a side menu, which appears on the right-hand side of the page. Code: <style type="text/css"> #SideMenu { color: #639; background-color: #FBFBFB; position: absolute; top: 275px; left: 630px; width: 190px; height: 250px; } </style> However, when the browser window is resized, the layer then obstructs the main content (by floating over it), and does not remain in its place as it should. This is how it should look like:: However, as the browser is resized, the layer does this: I'm tring to remedy this using CSS only, so please send any suggestions to me. The code for the sidebar is: Code: <div id="SideMenu"> <p>Side Content. I like to eat food.</p> </div> Any ideas guys?! I have a web page containing 3 layers. There are placed side by side with absolute positions. The middle layer contains a image with a fixed size. Now I have to change the image based on user's selection, so it is no longer fixed sized. I want to let the third (right) layer to re-adjust its position when image is smaller. How to make it work? This is my first time working with layers, please help. Thanks. Matt I have a webpage located at http://www.niu-sae.com I have a drop down menu image, in a div layer that will pop up when you roll over the first link "Active Chapter". First of all the positioning is all weird... when I am at full screen I have to set the div left at 285... even though it is really only about 116. any idea what I am doing wrong? Second even when I get it lined up... the way it is now... it changes if you resize the window. HELP. please. Hello All, Im currently stuck trying to get a layer on top of a layer. The image below shows the problem. img68.imageshack.us/img68/5579/picture3cl2.png And here is a link to a code version: thenpcs.com/beta/ Any help greatfully appreciated! Hi Guys, Basically I'm having trouble with getting the 'Content' div layer to wrap around the switching div layers. The grey background colour represents the 'Content' div layer which wraps around the button menu OK but doesn't wrap around the layers which switch. The bodged way of doing it is to have a fixed height but then it leaves a blank area underneath the divs that are short of text...If you get what I mean? Code: <div id="content_test"> <div id="rollovercontentwrapper"> <div id="tabwrapper"> <ul id="tabmenu"> <li><p><a href="#" onClick="javascript:showTabContentOne('TabContentOne')">Summary</p></a></li> <li><p><a href="#" onClick="javascript:showTabContentTwo('TabContentTwo')">Benefits</p></a></li> </ul><!--TABMENU--> </div><!--TABWRAPPER--> <div id="TabContentOne" class="TabContentOne" style="visibility: hidden"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lacus risus, porttitor non aliquam non, scelerisque vitae turpis. Duis venenatis nisl lectus, et aliquam eros. Nam commodo, ligula sed ultrices vehicula, justo augue ultricies urna, sed rhoncus nisi dui sed risus. Nullam commodo risus nec justo sagittis eu cursus nisi interdum.</p> <br> <p>In hac habitasse platea dictumst. Sed vulputate auctor cursus. Morbi ac ullamcorper dui. In sem velit, pulvinar sit amet cursus id, vulputate fringilla erat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed lorem urna, imperdiet eget fringilla eget, molestie nec justo. Fusce diam nulla, fringilla a sodales at, rhoncus vitae massa. Donec tincidunt, leo quis fermentum venenatis, purus elit tincidunt ipsum, vitae sollicitudin nulla orci nec arcu. Sed non neque neque, ac pharetra lectus. Donec a massa mauris. Sed vel magna eget tellus commodo placerat in quis risus. Aenean velit lectus, aliquam quis dictum ac, pellentesque sed diam.</p> </div><!--TabContentOne--> <div id="TabContentTwo" class="TabContentTwo" style="visibility: hidden"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lacus risus, porttitor non aliquam non, scelerisque vitae turpis. Duis venenatis nisl lectus, et aliquam eros. Nam commodo, ligula sed ultrices vehicula, justo augue ultricies urna, sed rhoncus nisi dui sed risus. Nullam commodo risus nec justo sagittis eu cursus nisi interdum.</p> </div><!--TabContentTwo--> </div><!--ROLLOVERCONTENTWRAPPER--> </div> <!----CONTENT_TEST----> <div id="onebyone" style="visibility:hidden;"> <img src="onebyonepixel.gif" onLoad="javascript:showTabContentOne('TabContentOne')" width="1" height="1"> </div> Code: div#rollovercontentwrapper { float: left; width: 630px; background-color: #E9E9E8 } div#tabwrapper { width: 630px; } ul#tabmenu { display: block; float: left; width: 630px; list-style-type: none; border-bottom: 1px solid #0048A7; } ul#tabmenu li { display: block; float: left; background-color: #E9E9E8; } ul#tabmenu li a { display: block; float: left; padding: 10px; background-color: #E9E9E8; border-top: 1px dashed #0048A7; border-right: 1px dashed #0048A7; } ul#tabmenu li a:focus { display: block; float: left; padding: 10px; background-color: #3383CD; border-top: 1px dashed #0048A7; border-right: 1px dashed #0048A7; } #TabContentOne { float: left; position: absolute; top: 350px; width: 628px; z-index: 1; padding-top: 10px; padding-bottom: 10px; } #TabContentTwo { float: left; position: absolute; top: 350px; width: 628px; z-index: 1; padding-top: 10px; padding-bottom: 10px; } div#onebyone { float: left; } div#content_test { float: left; width: 900px; padding: 20px; background-color: #CCCCCC; } Can anybody help me out on this? Many thanks, Mark I need to position a 200px high by 300px wide layer in the center of the page. does anyone know a simple way to do this, i have thought about using JS to calculate the width of the page, take off the 200px, and halve it, but that seems like overkill, isnt there a simple CSS command? Thanks Xaphan Well, I can't post links so this is going to be hard as hell to type out. I have a layer within that page that I want in a certain position, yet when I move the width of my browser the layer does not stay where I want it. Obviousely, this does not make any sense because its something you have to see. I checked the rules for the forums and I can't find where it states anything about URLs, if someone would be so kind to show me, I'd appericiate it. Not that it matters witout seeing it on the page but my code for this layer is: Code: <div id="Layer1" style="position:absolute; left:848px; top:85px; width:118px; height:167px; z-index:1"> <div class="mltop">schedule +4hrs </div> <p>00:00 - Music <br> 01:00 - Music <br> 02:00 - Music <br> 03:00 - <a href="">BRR</a></p> <p><b>Current time: 00:00</b><br> Times in CST/CDT <br> </p> </div> |