不确定我在这里做错了什么,但我似乎可以在我的一个div中找到一些文本。香港专业教育学院尝试使用text-align:center;在div上,设置宽度100%和margin:0,auto,但似乎没有任何工作。
这是代码和小提琴 感谢
.banner_category { float:left; width:195px; border:solid 1px #b3b3b3; border-radius:3px; margin:0 30px 30px 0; }
.banner_category.ban4, .banner_category.ban8 { margin-right:0; }
.banner_category .banner_img { border-radius:2px; overflow:hidden; }
.banner_category .banner_img img { max-width:100%; }
.banner_category .banner_holder {
padding:12px 2px 13px 2px;
margin: 0 auto;
text-align:center;
overflow:hidden;
background: #f3f3f3; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #f3f3f3 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #f3f3f3)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%, #f3f3f3 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%, #f3f3f3 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%, #f3f3f3 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%, #f3f3f3 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f3f3f3', GradientType=0 ); /* IE6-9 */
border-radius:0 0 2px 2px;
}
.banner_category:hover .banner_holder {
padding:12px 2px 13px 2px;
margin: 0 auto;
text-align:center;
background: #ff9c0e; /* Old browsers */
background: -moz-linear-gradient(top, #ff9c0e 0%, #ff7e06 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ff9c0e), color-stop(100%, #ff7e06)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ff9c0e 0%, #ff7e06 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ff9c0e 0%, #ff7e06 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ff9c0e 0%, #ff7e06 100%); /* IE10+ */
background: linear-gradient(to bottom, #ff9c0e 0%, #ff7e06 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff9c0e', endColorstr='#ff7e06', GradientType=0 ); /* IE6-9 */
}
.banner_category .banner_holder h2 { float:left; margin:0 0 0 0; font-size:14px; font-weight:500; text-transform:uppercase; color:#0a9be0; }
.banner_category .banner_holder i { float:right; margin:1px 0 0 0; font-size:14px; color:#333333; font-style:normal; }
.banner_category:hover .banner_holder h2 { color:#fff; }
.banner_category:hover .banner_holder i {color:#fff; }
<div class="banners_block">
<div class="banner_category ban1">
<a href="{{url=''}}">
<div class="banner_img"><img src="{{url="wysiwyg/image.png"}}" alt="" style="display: block; margin: 0 auto;"/></div>
<div class="banner_holder">
<h2>Center Text</h2>
</div>
</a>
</div>
</div>
答案 0 :(得分:1)
因为您h2
设置为float:left
。删除它,它很好
.banner_category .banner_holder h2 {
/*float: left;*/ //remove
margin: 0 0 0 0;
font-size: 14px;
font-weight: 500;
text-transform: uppercase;
color: #0a9be0;
text-align: center;
}
答案 1 :(得分:0)
删除行中的float: left;
:.banner_category .banner_holder h2 { float:left; margin:0 0 0 0; font-size:14px; font-weight:500; text-transform:uppercase; color:#0a9be0; text-align:center; }
。