html - 如何使用 Bootstrap 根据屏幕尺寸居中图像

标签 html css twitter-bootstrap

如何使用 Bootstrap 根据屏幕尺寸将个人资料图像居中?

这是我到目前为止所做的:

html:

<div class="col-md-12">
  <div class="col-md-2 col-xs-12">
    <div class="deck">
      <img src="https://image.tmdb.org/t/p/w220_and_h330_bestv2/kXlrGioGfFKOvibpsPzzGx16cP2.jpg" alt="list image" width="160">    
    </div>
    <div class="title-users-list-profile"> 
        <img class="comments-author" src="http://t0.gstatic.com/images?q=tbn:ANd9GcS_9j6SU0VDO8PQtsal3pvO2Xrp4eu2IbOYQVjLUDtRNQmn6PIBqDw3B4o" alt="image picture"/>
    </div>

  </div>

</div>

CSS:

.deck{
  display: flex;
}
.comments-author {
  border-radius: 50%;
  border: 6px solid #fff;
  margin: 5px;
  box-shadow: 0 0 0 5px rgba(0,0,0,.2);
}   
.title-users-list-profile img{
  position: relative;
  width: 50px;
  height: 50px;
  top: -35px;
  left:50px;
  margin-top: 8px;
  margin-bottom: -25px;
}

https://jsfiddle.net/tzc2gdcf/

最佳答案

您可以使用 flexbox 来对齐图像。 查看本指南:https://css-tricks.com/snippets/css/a-guide-to-flexbox/ 并使用 @media 对单个媒体大小的特定规则

关于html - 如何使用 Bootstrap 根据屏幕尺寸居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48123881/

相关文章:

html - 选择除最后一个以外的所有元素

javascript - 两种方式的数据绑定(bind)不适用于 knockout ObservableArrays

html - 某些元素不受使用伪类后的 z-index 的影响

javascript - 如何使用 formValidation 插件使用 "warning"而不是 "error"进行验证?

javascript - 弹出表单未出现在 Bootstrap 网站中

jquery - 使用 Ajax 的简单 POST 请求

php native 查询到codeigniter查询

html - 3 列 - 带溢流元件的中心列流体

css - jQuery UI Accordion 定位

javascript - jQuery 在一定时间后删除 Bootstrap 警报