该集装箱固执地拒绝居中。演示:http://codepen.io/Diego7/pen/KzXgZN集装箱不会中心
我已经尝试了几乎每个我可以在网上找到的中心代码,都无济于事。
从css中删除width: 90%;
将容器对齐到左侧,即使margin: 0 auto;
正在告诉它居中。
很抱歉,如果这个问题没有达到StackOverflow上的 '标准',但codingforums.com下跌的那一刻:(
感谢堆!
HTML
<div class="container">
<article>
<header>
<img src="https://softwarereviews.files.wordpress.com/2016/04/bg-header-no-logo.png" width="972px"><br />
<h2>Information</h2>
</header>
<p>There's currently is no information available. Sorry.</p>
<footer>
© 2016
</footer>
</article>
</div>
CSS
@@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);
body {
font-family: 'Open Sans', sans-serif;
background: #fff;
}
.container {
list-style:none;
margin:0 auto;
width:90%;
padding-top: 20px;
background: #fff;
border-radius: 6px;
box-sizing: container-box;
}
article header h2 {
color: #282828;
font-size: 1.2em;
font-weight: normal;
display:inline;
line-height: 1.3;
}
article p {
font-size: 1em;
display:inline;
line-height: 1.5em;
color: #282828;
max-width: 972px;
}
article footer {
font-size: .9em;
display:inline;
color: #999;
}
a {
color: #2790ae;
text-decoration: none;
outline: none;
}
a:hover {
color: #0f6780;
}
谢谢大家的回答!你是对的,它是集中的,我只是看不到它。 我不得不使'宽度'与图像的宽度相同,972像素,然后'文本对齐'左边。再次感谢 :) –