问题描述
我想整个块在其父为中心,但我想块的内容进行左对齐。
I want a whole block to be centered in its parent, but I want the contents of the block to be left aligned.
实例提供最佳服务
在本页面:
<一个href="http://yaml-online-parser.appspot.com/?yaml=%23+ASCII+Art%0d%0a---+%7c%0d%0a++%5c%2f%2f%7c%7c%5c%2f%7c%7c%0d%0a++%2f%2f+%7c%7c++%7c%7c__%0d%0a&type=python" rel="nofollow">http://yaml-online-parser.appspot.com/?yaml=%23+ASCII+Art%0d%0a---+%7c%0d%0a++%5c%2f%2f%7c%7c%5c%2f%7c%7c%0d%0a++%2f%2f+%7c%7c++%7c%7c__%0d%0a&type=python
在ASCII艺术应该是居中的(因为它出现),但它应该排队,看起来像YAML。
the ascii art should be centered (as it appears) but it should line up and look like "YAML".
或者这样:
<一个href="http://yaml-online-parser.appspot.com/?yaml=%3f+-+Detroit+Tigers%0d%0a++-+Chicago+cubs%0d%0a%3a%0d%0a++-+2001-07-23%0d%0a%0d%0a%3f+%5b+New+York+Yankees%2c%0d%0a++++Atlanta+Braves+%5d%0d%0a%3a+%5b+2001-07-02%2c+2001-08-12%2c%0d%0a++++2001-08-14+%5d%0d%0a" rel="nofollow">http://yaml-online-parser.appspot.com/?yaml=%3f+-+Detroit+Tigers%0d%0a++-+Chicago+cubs%0d%0a%3a%0d%0a++-+2001-07-23%0d%0a%0d%0a%3f+%5b+New+York+Yankees%2c%0d%0a++++Atlanta+Braves+%5d%0d%0a%3a+%5b+2001-07-02%2c+2001-08-12%2c%0d%0a++++2001-08-14+%5d%0d%0a
错误信息都应该排队,因为它在一个控制台。
the error message should all line up as it does in a console.
推荐答案
寄托其它问题工作答案:http://stackoverflow.com/questions/1232096/how-to-horizonatally-center-a-floating-element-of-a-variable-width/1232297#1232297
Reposing working answer from other question: http://stackoverflow.com/questions/1232096/how-to-horizonatally-center-a-floating-element-of-a-variable-width/1232297#1232297
假设这是自由浮动,将集中的元素一个div一个ID =内容......
Assuming the element which is floated and will be centered is a div with an id="content" ...
<body>
<div id="wrap">
<div id="content">
This will be centered
</div>
</div>
</body>
和应用下面的CSS
#wrap {
float: left;
position: relative;
left: 50%;
}
#content {
float: left;
position: relative;
left: -50%;
}
下面是关于该http://dev.opera.com/articles/view/35-floats-and-clearing/#centeringfloats
这篇关于CSS:中心块,但调整内容向左的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!