|
INTERVIEW QUESTIONS
WEB
CSS
DETAILS
Question: How do I center block-elements with CSS1?
Answer: 1. By setting the properties margin-left and margin-right to auto and width to some explicit value:
BODY {width: 30em; background: cyan;} P {width: 22em; margin-left: auto; margin-right: auto}
In this case, the left and right margins will each be four ems wide, since they equally split up the eight ems left over from (30em - 22em). Note that it was not necessary to set an explicit width for the BODY element; it was done here to keep the math clean.
Another example:
TABLE {margin-left: auto; margin-right: auto; width: 400px;} In most legacy browsers, a table's width is by default determined by its content. In CSS-conformant browsers, the complete width of any element (including tables) defaults to the full width of its parent element's content area. As browser become more conformant, authors will need to be aware of the potential impact on their designs.
|
|
|
Category |
CSS Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8868 users |
Added on |
9/4/2014 |
Views |
72009 |
Rate it! |
|
|
Question:
How do I center block-elements with CSS1?
Answer:
1. By setting the properties margin-left and margin-right to auto and width to some explicit value:
BODY {width: 30em; background: cyan;} P {width: 22em; margin-left: auto; margin-right: auto}
In this case, the left and right margins will each be four ems wide, since they equally split up the eight ems left over from (30em - 22em). Note that it was not necessary to set an explicit width for the BODY element; it was done here to keep the math clean.
Another example:
TABLE {margin-left: auto; margin-right: auto; width: 400px;} In most legacy browsers, a table's width is by default determined by its content. In CSS-conformant browsers, the complete width of any element (including tables) defaults to the full width of its parent element's content area. As browser become more conformant, authors will need to be aware of the potential impact on their designs. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What are Cascading Style Sheets?
|
View Answer
|
|
What is CSS?
|
View Answer
|
|
Can I attach more than one declaration to a selector?
|
View Answer
|
|
How do I get my footer to sit at the bottom?
|
View Answer
|
|
How To Style Forms?
|
View Answer
|
|
How To Style Table Cells?
|
View Answer
|
|
How far can CSS be taken beyond the web page--that is, have generalized or non-web specific features for such things as page formatting or type setting?
|
View Answer
|
|
What is initial value?
|
View Answer
|
|
What is value?
|
View Answer
|
|
How do I have links of different colors on the same page?
|
View Answer
|
|
How do you make a whole div into a link?
|
View Answer
|
|
Why shouldn't I use fixed sized fonts ?
|
View Answer
|
|
Which characters can CSS-names contain?
|
View Answer
|
|
How do you make a tool tip that appears on hover?
|
View Answer
|
|
What is the difference between ID and CLASS?
|
View Answer
|
|
Can I include comments in my Style Sheet?
|
View Answer
|
|
Is there anything that CAN'T be replaced by Style Sheets?
|
View Answer
|
|
How can I make a page look the same in e.g. NS and MSIE ?
|
View Answer
|
|
What are pseudo-elements?
|
View Answer
|
|
How do I write my style sheet so that it gracefully cascades with user's personal sheet ?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All CSS Interview Questions & Answers - Exam Mode /
Learning Mode
|