Css Centering

free web hosting
Open Discussion > CONTRIBUTE > Tutorials

Css Centering

KansukeKojima
Description
Learn to center the content, or other objects of your pages with CSS. This is a useful tool for creating succesful, and well designed web-pages.

Try it out

Create a new .css file called whatever.css. Alright, now input the following lines into your new css document.



CODE
#wrapper {
margin: 0 auto;
width: 800px;
}



Alright. Now that was fairly simple. The important part is the 'margin' property. The property is used to define where something is located from the sides of the screen, or from the insides of a container. By using the value 'auto' our page will automatically center itself across the screen. (Note: in this case, the id #wrapper, must contain all the content you wish to center on your page.)

Congratualations, you have just learned to center your pages with CSS. This is a very useful piece of knowledge to have, as it drastically improves the look of fixed width layouts.

 

 

 


Reply

dave2win
You can also do it in a different way. [This is just another process & the above process is also very good].

Suppose you want to center a 900px picture. You link that html file to an external CSS File & copy the following code:--

CODE
.center{
width:900px;
margin-left:-450px;
}


Here also the picture is centered with respect to its Parent. THe negative value for the margin tag allows the picture to move 450px in the left as a result it gets centered.

Now just add the class property to the img tag or whatever you want to center and put its value as center. Now you are done. Open the file in a Web Browser and see your creation.

Good Luck with your Project.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.


*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for css, centering

*MORE FROM TRAP17.COM*
advertisement



Css Centering



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE