terryds Posted September 5, 2013 Share Posted September 5, 2013 Look at : http://terryds.net63.net/ I want my #title Terry Djony Official Website get to the middle when the page-header becomes 200px or larger ( like the one in http://terryds.net63.net/ ) I want my #title get to the middle of the page-header no matter how high the page-header is... Any solutions ? Link to comment Share on other sites More sharing options...
davej Posted September 5, 2013 Share Posted September 5, 2013 You gave us the same link twice. Link to comment Share on other sites More sharing options...
terryds Posted September 6, 2013 Author Share Posted September 6, 2013 Sorry for my bad English skill ... I mean, in http://terryds.net63.net/ , then i inspect the elements , then i change the #page_header to 200px ... So, the #page_header height becomes 200px , but the #title doesn't automatically moved to the middle of the page header ... Can you tell me how to make the #title get to the middle of page header automatically even if the page header's height changes ? Link to comment Share on other sites More sharing options...
davej Posted September 6, 2013 Share Posted September 6, 2013 (edited) By "middle" I guess you mean vertical centering? I don't know how to do it automatically when you have float involved. You need one of the css gurus to answer that. All I can offer is a manual adjustment... #title { text-align: center; line-height: 150px; /*vertical-align: middle;*/} Edited September 6, 2013 by davej 1 Link to comment Share on other sites More sharing options...
terryds Posted September 8, 2013 Author Share Posted September 8, 2013 Can you tell me why vertical-align:middle doesn't work ? Link to comment Share on other sites More sharing options...
dsonesuk Posted September 8, 2013 Share Posted September 8, 2013 If you want it to work how you want it, give parent element display: table;, and header title display: cell; and apply vertical-align: middle to this as well, you will have to make adjustments to the nav, but it should position text in middle vert/horz. 1 Link to comment Share on other sites More sharing options...
DarkxPunk Posted September 8, 2013 Share Posted September 8, 2013 I agree with dsonesuk. If you make the #page_nav display: table-row and give it a height of 0 and a width of 100%, and than the #title display: table-cell. It works fine. Personally I think you could improve on the code using these suggestions so play around. 1 Link to comment Share on other sites More sharing options...
terryds Posted September 8, 2013 Author Share Posted September 8, 2013 Thanks for the answer.... It works well.... But, i want to ask something.. Does vertical-align just work for table ? Link to comment Share on other sites More sharing options...
dsonesuk Posted September 8, 2013 Share Posted September 8, 2013 No, check out http://www.w3schools.com/cssref/pr_pos_vertical-align.asp for example Link to comment Share on other sites More sharing options...
terryds Posted September 14, 2013 Author Share Posted September 14, 2013 Yeah, i have opened that link.... But, i still wonder why i should make it display as table... In http://www.w3schools.com/cssref/pr_pos_vertical-align.asp , it says when the vertical-align:middle, it will make it placed in the middle of parent element. But, if i just use vertical-align : middle without displaying it as a table, it doesn't work... Can you tell me why i should use display:table ? Link to comment Share on other sites More sharing options...
dsonesuk Posted September 14, 2013 Share Posted September 14, 2013 Because its more relation to the text, use of table/cell is in relation to cell height, much like a normal table. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now