html - 如何在DIV中居中DIV?

标签 html css footer 960.gs

我有一个正在构建的页脚。

我希望能够将页脚中的 4 个 div 居中(例如第一段或 5 个图标(无法呈现))。执行此操作的最佳方法是什么?

演示:http://jsfiddle.net/8q5ek/3/

CSS:

#insidefooter, #disclaimer {
max-width: 960px;
min-width: 960px;
margin-left: 25%;
margin-right: auto;
}
#footer {
color: #C9C9C9;
min-width: 1500px;
background-color: #2d2d2d;
list-style: none;
height: 450px;
background-image:url(http://i.imgur.com/yb7j6PD.png);
background-repeat:repeat;
}
#insidefooter {
margin-top: 20px;
text-align: center;
}
/*settings for social media buttons*/
 #insidefootertermsplusbuttons li {
display: inline;
color: #C9C9C9;
}
#insidefooterone1 h5, #insidefootertwo1 h5, #insidefooterthree1 h5, #insidefooterfour1    h5 {
text-align:left;
margin-bottom: 0;
padding-bottom: 0;
color:#FFFFFF;
padding-left: 0px;
}
#insidefooterone1 li, #insidefootertwo1 li, #insidefooterthree1 li, #insidefooterfour1 li {
list-style: none;
text-align: left;
margin-left: 0;
color: #C9C9C9;
padding: 0;
}
#insidefooterone1 ul, #insidefootertwo1 ul, #insidefooterthree1 ul, #insidefooterfour1 ul {
list-style: none;
text-align: left;
padding-left: 0px;
padding-right: 0;
color: #C9C9C9;
overflow: hidden;
}
#disclaimer {
margin-top: 20px;
font-size: 9px;
text-align: center;
margin-bottom: 0;
}
#disclaimer p {
text-align:center;
color: #C9C9C9;
}
.ul_links {
overflow: auto;
display: inline-block;
min-width: 700px;
}

最佳答案

我解决了你的问题。 所以我反复研究了您的代码,做了很多更改,结果如下:

http://jsfiddle.net/rYjS9/7/

实际的技巧是使用 display: inline-block;margin-left: auto; margin-right: auto; 以及我更改的其他一些内容,正如您从 jsfiddle 中看到的那样。 ;)

问候

关于html - 如何在DIV中居中DIV?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23358790/

相关文章:

jquery - 如何将 CSS table-striped 类添加到 jQuery Datatable 中动态生成的行?

css - 粘性页脚问题 - 页脚下突然显示空白

html - 使用图像制作边框 CSS3

javascript - 如何去除主动效果

html - 居中对齐 navbav 列表项中图像下方的文本

html - 使用存储在外部 css 中的字体

javascript - 我如何将这个图像和评论 div 与 css 结合在一起?

CSS 舍入在 Safari 中有效,但在 Chrome 中无效

css - 背景 CSS 100% 宽度水平滚动问题

schema - Shopify 定义架构