CSS - Format Tables Vertically, <br>, Etc...
Suppose I have a few tables I want to format vertically. If they are quite wide, chances are simply doing <table id="a">...</table> this will probably happen automatically. Ever, with a wide enough screen they might format horizontally.
To fix this, I could to the following: <table id="a">...</table><br><table id="b">...</table><br><table id="c">...</table> but unfortunately, <br> also adds extra unwanted spacing. Is there a was to CSS the <br> tag to avoid this, or is there a CSS method to indicate that each successive table should be below the last, not to the right? Skolem Similar TutorialsHi all, I know there are certain tricks to vertically center texts or images in a div area. And I have read somewhere there are plans to avoid current complexity compared with tables. For example, provided I use same CSS... Code: div,table{ width: 250px; height: 100px; border: 1px solid red; text-align: center; } ...we optain well vertically centered text in this table... Code: <table> <tr><td>this IS vertically centered</td></tr> </table> ...but not in this div based one... Code: <div>this IS NOT vertically centered</div> I ask, do you know an easy way to acomplish the same we get with tables? Thanks! Lately, I see articles everywhere telling us to ditch tables and use CSS to position forms. I don't necessarily have a problem with using CSS although I'm admitedly a bit new to using it for anything more than basics like sizing, color, borders and backgrounds. But my basic question is why ditch the tables? Tables have been around since the inception of html. They work with any browser you care to name and the provide a valid function allowing developers to position things on the screen in a pleasing manner. The flow of data in tables is simple, so the developer and usually the user can predict where the cursor will go when the user hits the tab key. There are certainly problems with tables, such as text wrapping or being truncated when the screen resolution is lower than the developer designed for and the positioning is not as clean as absolute positioning with CSS. Absolute positioning with CSS can lead to its own problems though. If the user has fonts set to a different size or odd video settings the size of the object positioned may not be large enough to display the text. This can cause object to overlap making the page unreadable. It may sound as if I'm just trying to hang on to the old way of doing things, and there may be a bit of truth in that, but more I'm asking for valid reasons to change the way I do things. I actually like finding new ways of doing things but there has to be a benefit to it. How will swithing to CSS layout instead of tables make my pages better for my users or easier to develop and maintain for me? I look forward to your responses. my layout is a left border, main content, then right border, all vertical columns. here is their code: Code: .left { background-image: url('images/obj_left.gif'); background-repeat:repeat-y; width:28px; margin:0px; } .maintable { width: 100%; background-color:#FFFFFF; border-left:3px solid black; border-right:3px solid black; } .right { background-image: url('images/obj_right.gif'); background-repeat:repeat-y; width:28px; margin:0px; } i also float them left, so imagine that is there. so i have code like this <div class='left floatleft'></div> <div class='maintable floatleft'></div> <div class='right floatleft'></div> but why cant i see the images in right and left? Hey everyone, my first time exploring page layouts using CSS and I'm having a few problems. I have a simple page with separate Header, Navigation and Content divs stacked on top of each other inside of a wrapper div (used to align the three to the center), with another div for the Footer placed below everything else. Here's how it looks now: Code: <html> <head> <title>CSS Divisions</title> <style type="text/css"> #Wrapper { width:800px; margin-left:auto; margin-right:auto; text-align:left; } #Header { width:800px; height:120px; background:#FC6;} #PNav { width:800px; height:40px; float:left; background:#CCC; } #Content { width:800px; height:400px; float:left; overflow:hidden; background:#FFC; } #Footer { width:100%; height:80px; float:left; text-align:center; background-color:#FC6; } </style> </head> <body> <div id="Wrapper"> <div id="Header">Header</div> <div id="PNav">Navigation</div> <div id="Content">Content</div> </div> <div id="Footer">Footer</div> </body> </html> Ideally what I want is for the page to look exactly how it is, but with the footer stretching from the bottom of the Content div, down to the bottom of the wherever the user's browser has loaded; basically to fill the vertical remainder of the screen. I've tried setting the footer height to 100%, but that forces the page to extend vertically, and I fumbled around with about a dozen other techniques not really knowing what I was doing, and I've had no luck so far. Any help would be greatly appreciated! I am aware of how difficult it is to vertically align text etc using pure css but what is hte best way to do it. For example i want to put some text slap bang into the middle of the screen. Thanks i'm trying to vertically align a div box (the sign in area) so that it sits on top of this grey (soon to be) navigation bar...i've floated the box to the right...i want it to align to the bottom now...can anyone help me? ------> http:// www . u2station . com / index2.php and the stylesheet is at: http:// www . u2station . com /movabletype/mt-static/support/themes/u2station/u2station.css i've basically been trying to radically modify an existing theme that movable type (MT) publishing system created so i can alter it to my specs. any quick help with this simple css adjustment would be extremely helpful...(otherwise i'm thinking of reverting back to old fashioned tables as a last resort). I started out working out a page thinking this *should* do what I want and lo and behold it did work in IE6 http://www.fogcat.co.uk/example/test002.html But when looking at Firefox it goes all odd. If you remove all the internal "imagediv" div from the "imagechunk" div it nearly works but doesn't algin the "link text" like IE. I'm told that display:inline-block is not properly supported, which is probably the root of my problems. What I want a set of divs down the page (the "imagedivs") Each div will contain An image - but that image will be nested inside a div - it's returned that way from a php function. Images may be of varying height so I can't use pixel values at top margins or anything like that. A link to another page The link should be positioned to the right of the image and aligned vertically with the centre of the image. This is one of those things that's a doddle with tables, but I'm trying to train myself to think CSS. What obvious thing am I over looking? Code: +--------------------------------------+ | +----------------+ | | | .............. | | --- <div> | | : : | | ... <img> | | : : | Link here | | | : : | | | | .............. | | | +----------------+ | +--------------------------------------+ +--------------------------------------+ | +----------------+ | | | .............. | | | | : : | | | | : : | Link here | | | : : | | | | .............. | | | +----------------+ | +--------------------------------------+ Hello, how do you align vertically a radiobutton with label without using the <br> tag in css? Code: <fieldset> <legend>Food</legend> <input name="Password" type="radio" id="p" value="" checked="checked" /> <label>HTML</label> <br /> <input name="n1" type="radio" id="p" value="" /> <label>ASP</label> <br /> <input name="n1" type="radio" id="p" value="" /> <label>Donut</label> <br /> <input name="n1" type="radio" id="p" /> </fieldset> Hey, I've been doing a fair amount of research on centering a page vertically and horizontally with CSS, and before I begin constructing my page, I thought I'd get some input from you guys. Basically, the page is going to look like this Any advice would be greatly appreciated. Thanks! Hi guys, I am trying to display two forms with several elements on a page. I would like to place the two forms on the webpage so that one is displayed on the left and the other on the right of the screen. Something like this URL http://craigbaldwin.com/blog/wp-content/uploads/2008/12/52.jpg I have written the following test and the forms are placed correctly inside the left and right divs. Code: <HTML> <Head> <style type="text/css"> div.wrapper { position: relative; clear: both; width: 100%; border : 1px solid #000000; } div.left { float: left; width: 50%; background: #ffffff; border : 1px solid #000006; } div.right { float: right; width: 50%; background: #ffffff; border : 1px solid #000001; } </style> </Head> <Body> <div class="wrapper">Wrapper <div class="left">Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box </div> <div class="right">Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box </div> </div> </Body> </HTML> A couple of problems with the above. 1. In Internet explorer the divs are aligned correctly but in firefox it gets all messy. 2. As long as the window is maximised then i the divs are aligned vertically correctly. If i resize the browser window then they are no longer aligned vertically. Is there a way to make them always next to each other from left to right even if the window is resized? (try resizing the window for the example i showed above) Thanks I have a navigation bar that contains four images (side by side) as well as three text links. They all live within a <div> with the following properties: #gNav { width:768px; height:19px; text-align:left; vertical-align:middle; } i need for the three text links to line up directly in the middle (vertically) of that <div>. To achieve this in IE6 and NN+, I attach the following style to the text. .nookum { font-size:.9em; vertical-align: 25%; color:#FFFFFF; } I just learned that the vertical-align property is not recognized by IE5 and IE5.5, so in those versions, the text aligns at the bottom of the <div>. Anyone know of any workarounds or other methods of vertically aligning text that will work in these two versions of IE? hi i would like to display some pictures on my site, and be able to scroll horizontally, i have simply listed the pictures in the xhtml and my css cose is below. at the moment the pictures still stack up vertically so the horizontal scroll bar cannot be used. can anyone help? thanks div.galleryscroll { height: 125px; width: 694px; position: absolute; top: 540px; left: 280px; z-index: +1; overflow-y: hidden; overflow-x: scroll; } So I'm still on my quest to be able to create my 1st entirely CSS site, and need some help as I'm not sure how to do this. I want to be able to align a navigation list at the bottom right of the content area. Also while I'm at it, I want the site to be at a minimum 462px (just an example), but would like for it to increase in height if the content itself expands beyond the 462. And the navigation menu, I'd like to somehow keep at the bottom right of the viewable area. Thanks... here's the code... HTML Code: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" /> </head> <body> <div class="outer"> <div class="logo"> <img src="images/logo.gif" /> </div> <div class="spacer"> </div> <div class="nav"> <a href="#">Link 1</a><br /> <a href="#">Link 2</a><br /> <a href="#">Link 3</a><br /> <a href="#">Link 4</a><br /> <a href="#">Link 5</a><br /> <a href="#">Link 6</a> </div> <div class="content"> <p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." </p> </div> </div> </body> </html> CSS Code: Code: body {padding:0px; margin:0px; } div.outer {background-image:url('images/bg2.jpg'); background-repeat:no-repeat; width:770px; height:462px; } div.logo {text-align:right; padding:10px; height:75px; } div.spacer {float:left; width:200px;} div.nav {float:right; text-align:right; padding:20px; } div.content {background-image:url('images/bg3.jpg'); width:400px; padding:20px; } .nav a{text-decoration:none; color:black; font-size:20px; font-family:"sans serif", verdana, arial; } .nav a:hover{text-decoration:underline; } Hi, Just upgraded my monitor and am now operating on a 1280*1024 resolution. Previous website I have built have been for 1024*768 resolutions. Problem is now that some of my images are placed at the top of the screen when I want them in the middle... not with a load of blank space beneath them. I want the blank space equally around them. Anyway, I'm specifically talking about the website I have: http://www.atari-music.co.uk The front and home-pages suffer from this problem when viewed on > 1024*768 resolutions. I have attempted to fix the problem (though it is not in the code for the on-line version) by putting this into the style sheet:- IMG.middle { vertical-align: middle; } In the HTML for the image map I have:- <IMG class="middle" src="images/home.jpg" height="570" width="760" alt="ATARI - The Official Website" border="0" usemap="#siteMap"/> Am I not referencing the CSS code correctly? The image is still sitting, vertically aligned to the top. Cheers, Rob. OK, I have three images: a top, middle, and bottom that need to align vertically. It should look like a typewriter with paper coming out when said and done. You can see what's wrong at csshore(dot)com Here is the css: #top { background:url(images/top.gif) no-repeat; background-position:50%; width: 617px; float:none; margin:0 auto; height: 55px; position: relative; } #container { background:url(images/middle.gif) repeat-y; background-position:center; width: 601px; padding:0; margin:0 auto; height: 100%; position: relative; min-height:600px; } #bottom { background:url(images/bottom.gif) no-repeat; background-position:50%; width: 800px; height:485px; margin:0 auto; position: relative; } .center { background-image:url(images/wood014.jpg); } And the html: <div id="top" class="center"></div> <div id="container" class="center">When in the course of human events, it becomes necessary for a people to through off the reigns of governement and create a new one. </div> <div id="bottom" class="center"></div> Ignore the failed attempt to quote the Declaration of Independence. I have tried everything I know (which admittedly is little) and I can't get them to align. Thanks in advance. Ok, Im somewhat of a newb when it comes to CSS so forgive me if any of thise doesnt make sense. Im writing a page that has 3 sections, a top-menu section, a middle dynamic section and a bottom static section. Ive elected to use layers to display content in the middle section based on a mouseclick in the top section. To do this Ive made used of a script that encloses the dynamic section in a div, with subsequent nested divs set to visibility: none until they are called to be displayed. The issue that I am having is I am trying to position the bottom static section, that should always remain visible, below the middle section depending on the height of the midle section. Essentially the bottom section should move vertically as the size of the midle section changes sizes. The style that Im using is: Code: <style type="text/css"> #container { position:relative; width:495; height: 400px; z-index:100 } .lyr { position:absolute; visibility:hidden; left:0; top:0; z-index:1 } .layer { } </style> This is an example of the code in the body: Code: <a href="#" onClick="swapLayers('lyr0'); return false"><font>Click to return to the Welcome Text</font></a><br /> <a href="#" onClick="swapLayers('lyr1'); return false"><font>Click to return to the Welcome Text</font></a><br /> <a href="#" onClick="swapLayers('lyr2'); return false"><font>Click to return to the Welcome Text</font></a><br /> <div id="container"> <div id="lyr0" class="lyr">Layer 1</div> <div id="lyr1" class="lyr">Layer 2</div> <div id="lyr2" class="lyr">Layer 3<p> Continuing layer 3</p><p> Continuing layer 3</p></div> <div class="layer">Layer 4</div> </div> With the above example Layer 1-3 will display based on mouseclicks. Layer 4 should appear beneath the currently displayed layer, and re-position accordingly based on the size of the preceding DIV. Does this make sense? Im not sure if Layer 4 should be nested inside the container div or below it. Thnx in advance for any help. hi guys, having a few problems laying out div's on my page.... http://www.coltontooling.co.uk/test.php (all the css is in style tags in the page itself) I have one div surrounding all content called wrapper, which just centers the page. Then I have the orange bar and menu bar, and the white div which is called main content. My problem is trying to get the last grey bar to sit nicely at the bottom of the page. I placed it at the bottom of the white maincontent div with a negative margin-bottom, but as you can see (in firefox at least) it hovers almost at the bottom, but not quite far down enough. No matter what I change the margin-bottom to, it will not move down any further. My other attempt was to put it outside the maincontent div at http://www.coltontooling.co.uk/2.php , but as you can just about see it sits at the top behind the maincontent div. I could move it down manually from here but then it wont match any dynamic content in the maincontent box. Am i missing something obvious here? I'm pretty stumped thanks a lot, tom is it possible to center something vertically inside a container without the use of tables? I know you use text-align to center horizontally, but what is used for vertical alignment? vertical-align doesn't work. PHP Code: <div style="width:100% height:100%; text-align:center;"> <!-- code goes here --> </div> thanks goran. DIV blocks display incorrectly in IE8 and it's driving me insane.. I tried adjusting padding for each column amongst other things but no dice! Everything looks fine in FireFox and IE9. I'm not allowed to post links as a new user but the website is dmstriping dot com. You'll have to fix the below links yourself. Any help would be greatly appreciated! **Here are the css files:** dmstriping dot com/new site/css/style.css dmstriping dot com/new site/css/layout.css Web Site: dmstriping dot com/new site/index.html |