February 20, 201016 yr Okay well I've been designing for a bit but I'm ashamed to admit I was doing it the tables way! I know! Anyway... Say I want to create something with images as borders like... the table way would be to create a table with three rows and three columns... these nine squares would then make the middle square for content, top left for a top left corner, top right for a top right corner etc. etc. How could I achieve this with CSS? I'm guessing DIVs? This has lead me on to another question too whilst I'm at it... How the HELL do you put two or more divs next to each other horizontally? Thanks, - Ash
February 20, 201016 yr Hi Ash Gonna post a quick one here as i am shattered and need some sleep.... You don't or never will put DIV's next to each other horizontally by just using mark-up. All you do is put each one underneath each other and float them using css. xhtml: <body> <div id="one"> </div> <div id="two"> </div> <div id="three"> </div> </body> The CSS: #one { float: left; background: #ccc; width: 200px; height: 200px; margin: 4px; } #two{ float: left; background: #ccc; width: 200px; height: 200px; margin: 4px; } #three { float: left; background: #ccc; width: 200px; height: 200px; margin: 4px; } Take away the floats(float: left;) and you will see....
February 20, 201016 yr Author I seeeee. I've used that with DIVs before when transitioning from tables to DIVs but it just seems like so much extra work load? Oh well, separates the men from the boys I guess so... I'll have to stick with it! Thanks alot!
February 20, 201016 yr Author Here's a question.. I have three divs aligned next to each other using floats but... I want it all to be aligned in the center of the page? On which divs do I put margin-left: auto and margin-right: auto?
February 20, 201016 yr Here's a question.. I have three divs aligned next to each other using floats but... I want it all to be aligned in the center of the page? On which divs do I put margin-left: auto and margin-right: auto? Wrap them all in a div with "margin:0 auto;" Simple!
February 21, 201016 yr I seeeee. I've used that with DIVs before when transitioning from tables to DIVs but it just seems like so much extra work load? Divs: <div id="3column"> <div id="1"></div> <div id="2"></div> <div id="3"></div> </div> #3column div { float: left; } Tables: <table> <tr> <td id="1"></td> <td id="2"></td> <td id="3"></td> </tr> </table> Not really too much work.
February 21, 201016 yr Divs: <div id="3column"> <div id="1"></div> <div id="2"></div> <div id="3"></div> </div> Shouldn't the first id be a class instead? considering you're putting a class of content inside it?
February 21, 201016 yr Shouldn't the first id be a class instead? considering you're putting a class of content inside it? It depends, if that code (and layout) was repeated elsewhere in the design I'd be more tempted to use a class but just like that an ID is fine. As per the aligning in the centre question, add another div around those already floated and add the following CSS to it: margin: 0 auto; .
February 21, 201016 yr In order to center the design using margin: 0 auto; you need to specify a width.
February 21, 201016 yr Shouldn't the first id be a class instead? considering you're putting a class of content inside it? The IDs should be called something else though, they're not supposed to start with numbers.
February 21, 201016 yr Shouldn't the first id be a class instead? considering you're putting a class of content inside it? deciding if it is a class or a ID has nothing to do with putting a "class of content" inside that wrapper. It all depends on if that element is going to be reusable on that page or not. If it is not going to be reused, then ID is best. if it is going to be reused, then you would use a class. The IDs should be called something else though, they're not supposed to start with numbers. Yes, but Im not building a semantic webpage, I'm showing an example.
Create an account or sign in to comment