This is a discussion on "[SOLVED] Centering!" within the Web Page Design section. This forum, and the thread "[SOLVED] Centering! are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] Centering!
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
[SOLVED] Centering!
ok. my css is this...
my html is this...
it doesn't center. lol
Last Blog Entry: My blog? (Oct 18th, 2007)
Last edited by mcdanielnc89; Oct 21st, 2007 at 18:27. Reason: WHen inserting code i didn't put the < in the front, but still doesn't work. |
|
|
|
|||
|
Re: Centering!
Dare I point out the obvious, though I'm sure its just a mistake:
|
|
|||
|
Re: Centering!
Quote:
Applying margin: 0 auto; to an element will cause it to be centred inside the parent container (but this fails on IE5 and IE6 in quirks mode). Do a search, either here or on Google. This has been covered many, many times. |
|
||||
|
Re: Centering!
This should work as it usually requires you to specify a height and width:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Centering!
Total server work required for CSS solution: 571B
Total server work required for align='center': 528B Try it yourself: http://www.rossandrus.net/examples/d...d/standard.php http://www.rossandrus.net/examples/d...deprecated.php Test the load time: http://www.websiteoptimization.com/services/analyze/ That's not even taking IE5 and 6 into consideration. The CSS solution also forces you to display the image as block which is less flexible for things like rows of horizontally centered icons, etc. Deprecated doesn't always mean bad. |
|
|||
|
Re: Centering!
hmm ok so which way is teh way to do itr if it's depreciated, and tyhe height and width would be pointless to do as that vlass is used for several other images...
Last Blog Entry: My blog? (Oct 18th, 2007)
|
|
||||
|
Re: Centering!
I just told you how to do iit the non-depcricated way.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Centering!
Quote:
You've got to be kidding me. Compared to the total work required for a typical webpage, this is irrelevant. It's far more important to understand the reasons for preferring CSS-based presentation to HTML-based presentation. Saving a few bytes here and there is of dubious value. Moreover, since both pages are invalid HTML, they hardly constitute good examples. Finally, note that although the CSS solution has an initial performance cost, it becomes more efficient the more you use it. Quote:
Quote:
Last edited by MikeHopley; Oct 21st, 2007 at 18:15. |
|
|||
|
Re: Centering!
Quote:
Last Blog Entry: My blog? (Oct 18th, 2007)
|
|
|||
|
Re: Centering!
You should not state the height and width. For images inserted via the <img> element (as opposed to CSS backgrounds), the height and width are given in the HTML.
Width is required for centring other boxes (<div>s, typically) that lack an inherent width. |
|
|||
|
Re: Centering!
If that is the case MikeHopley then what is wrong with my code to make it not center? Is my CSS wrong?(Obviously it has to be)
Last Blog Entry: My blog? (Oct 18th, 2007)
|
|
|||
|
Re: Centering!
Quote:
I suspect this is IE nuttiness. But the simplest explanation requires that I know more about your browser/code. |
|
|||
|
Re: Centering!
Quote:
Quote:
Quote:
http://validator.w3.org/check?uri=www.google.com |
|
|||
|
Re: Centering!
Yes it is IE7, and a link to where one of the images not responding is located here.
Last Blog Entry: My blog? (Oct 18th, 2007)
|
|
|||
|
Re: Centering!
You need to set the class of your images to link with the information in your stylesheet. Your code modified:
http://centricle.com/ref/css/filters/ But make sure your code is sound before you start looking into browser discrepancies. |
|
|||
|
Re: Centering!
Quote:
Quote:
Quote:
|
|
|||
|
Re: Centering!
ok. my css is
Last Blog Entry: My blog? (Oct 18th, 2007)
|
|
||||
|
Re: Centering!
Why not
|
|
|||
|
Re: Centering!
Are you sure you've updated your styesheet? The style rules are not present.
|
|
|||
|
Re: Centering!
HTML objects can be rendered as either inline or block.
Inline elements like <span> and <img> have no default margins or padding and are intended to display on one line (not multiple lines) and therefore have no height attribute. If you try to specify the height of an inline element you will fail. Block elements like <div> and <p> are intended as a block. There is default margin and padding (a carriage return to the user) and you can specify height and width attributes. The CSS specifies the horizontal AND vertical margins for the image:
Read about margins: http://www.w3schools.com/css/pr_margin.asp And inline vs. block elements: http://www.webdesignfromscratch.com/...and-inline.cfm |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Centering Vertically | R8515198 | Web Page Design | 5 | Dec 6th, 2007 11:05 |
| [SOLVED] page centering issues | VanderBOOM | Web Page Design | 12 | Dec 4th, 2007 15:06 |
| [SOLVED] Centering horizontally and vertically | Emzi | Web Page Design | 4 | Nov 1st, 2007 16:07 |
| [SOLVED] Problems with centering in CSS. | mcdanielnc89 | Web Page Design | 26 | Nov 1st, 2007 06:07 |
| Tip : Vertical and Horizontal Centering - Solved! | gwx03 | Web Page Design | 0 | Dec 15th, 2003 06:11 |