html - 特定 div 中所有媒体屏幕的中心元素

标签 html css twitter-bootstrap

我正在使用 Bootstrap 框架进行设计 我遇到了一些屏幕尺寸的问题,因为这个网站是响应式的 我可以通过针对每个媒体来解决这个问题,但我认为通过使用带有 Bootstrap 的定义类可以解决这个问题 这个问题我只想在所有媒体屏幕的中心放置一些元素,为了解释它我更喜欢使用图像
在大屏幕上没问题 enter image description here

但在其他媒体 enter image description here

这是代码提示

 <div class="socialicons center-block">
                 <a href="#"><i id="social-user" class="fa fa-facebook-square fa-2x social-fb"></i></a>
                <a href="#"><i id="social-user" class="fa fa-twitter-square fa-2x social-tw"></i></a>
                <a href="#"><i id="social-user" class="fa fa-google-plus-square fa-2x social-gp"></i></a>
                <a href="#"> <i id="social-user" class="fa fa-linkedin-square fa-2x social-tw"></i></a>
            </div>

我试过这个 CSS

display: block;
margin-right: auto;
margin-left: auto;

和 margin :0 自动;

最佳答案

谢谢大家的评论 我按照@amitrh 的指示制作,这对第一个元素 block 工作正常,并且在所有屏幕上都这样工作 enter image description here

并且链接出现在我想要的中心,并通过应用此代码出现在 block 中

.socialicons {
    display: table;
    margin: auto;

对于最后一个中的第二个 block ,它有另一个行为,因为字体图标比第一个中的图标大,就像这样 enter image description here 这也是 enter image description here 所以我将CSS更改为

display: inline-table;
margin: auto;

并且像这样在所有屏幕中工作正常并在左侧居中 enter image description here

感谢您的评论和代码提示,因为您节省了我的时间,这帮助我解决了我的问题,而无需 css hack 或其他不必要的代码 @box86rowh @amitrh @BootstrapBoogie - 克里斯蒂娜

关于html - 特定 div 中所有媒体屏幕的中心元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27548535/

相关文章:

html - HTML 中特殊的不存在元素空间

css - Webkit 滚动条边框动画

html - 在 bootstrap css 中垂直对齐缩略图?

html - bootstrap css,如何在容器内制作全宽div

javascript - 支持 div 打开时避免在主要内容中滚动 - 仅限移动设备

html - 将包含 3 个 float div 的容器居中到左侧

html - CSS 表格响应格式

html - iframe 阻止 z-index 工作?

css - 推特 Bootstrap : force elements to be below each other on mobile devices

javascript - 将 json 放入模态