页面中的中心配置文件卡

时间:2017-11-28 23:59:42

标签: html css

我目前有四张个人资料卡,我试图找到一种方法将它们置于页面中心,相应地。我让它们向左浮动,但是一旦我将它们居中,它们就会垂直叠加在一起。在移动设备和平板电脑视图方面,这尤其成为一个问题。有没有办法解决这个问题并将所有四个显示在一行中?

提前感谢您的帮助。



a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: rgba(0, 0, 0, .65);
}

a:hover {
  color: rgba(0, 0, 0, .45);
}

.window,
.box,
ul,
li {
  margin: 0;
  overflow: hidden;
  padding: 0;
  position: relative;
}

ul {
  font-family: 'Fjalla One', sans-serif;
  list-style-type: none;
  text-transform: uppercase;
}

li {
  display: inline-block;
}

img {
  display: block;
  width: 100%;
}

.btn {
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 40px;
  color: rgba(0,0,0,0.75);
  display: block;
  font-size: 1em;
  font-weight: 400;
  height: 44px;
  letter-spacing: 5px;
  line-height: 42px;
  margin: 10px auto;
  padding: 0;
  position: relative;
  text-align: center;
  text-transform: uppercase;
  -webkit-transition: all .5s ease;
  transition: all .5s ease;
  vertical-align: middle;
  width: 60%;
}

.btn:hover {
  background: rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.15);
}

.overlay {
 
  background-size: cover;
  height: calc(100% + 40px);
  margin: -20px;
  position: relative;
  width: calc(100% + 40px);
}

.window {
  
  height: 560px;
  margin: 2em auto 0;
  width: 300px;
  float: left;
  padding: 5px;
}

.header {
  background: blue;
  color: #FFF;
  height: 380px;
  left: 0;
  position: absolute;
  text-align: center;
  top: 0;
  width: inherit;
}

.header:before {
  border: 2px solid rgba(161, 220, 255, 0.34);
  border-radius: 100%;
  content: "";
  height: 140px;
  left: 0;
  margin: 67px auto;
  padding: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 140px;
  z-index: 2;
  -webkit-transform: scale(1.24, 1.24);
  -moz-transform: scale(1.24, 1.24);
  transform: scale(1.24, 1.24);
}

.header img {
  border: 5px solid #A1DCFF;
  border-radius: 100%;
  height: 140px;
  margin: 4em auto 2.5em;
  object-fit: cover;
  width: 140px;
}

.header h2 {
  display: inline-block;
  font-family: 'Quicksand', sans-serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -2px;
  margin: 0 auto;
  padding: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.header h4 {
  color: rgba(255, 255, 255, 0.75);
  display: block;
  font-size: 15px;
  margin: 0 auto;
  padding: 5px 0 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  text-transform: uppercase;
}

.footer {
  background: rgba(0, 97, 145, 0.75);
  bottom: 0;
  color: #FFF;
  left: 0;
  position: absolute;
  text-align: center;
  top: 380px;
  width: inherit;
}

.footer ul {
  display: flex;
  font-size: 16px;
  font-weight: 400;
  height: 40px;
  line-height: 40px;
  padding: 20px 20px;
}

.footer li:first-child {
  border: 0;
}

.footer li {
  border-left: 2px solid rgba(255, 255, 255, .15);
  font-family: 'Quicksand', sans-serif;
  padding: 0 4px 0 6px;
  width: 100%;
}

.footer a span {
  color: #9CDFF5;
  display: inline-block;
  font-size: 26px;
  padding: 0 4px 0 0;
  vertical-align: middle;
}

<div class="container">
<div class="window">
  <div class="overlay"></div>
  <div class="box header">
    <img src="http://via.placeholder.com/350x150" alt="" />
    <h2>Nera Parian Mohn</h2>
    <h4>Norway</h4>
  </div>
  <div class="box footer">
    <ul>
      <li><a href=""><span class="ion-ios-camera-outline"></span> 401</a></li>
      <li><a href=""><span class="ion-ios-heart-outline"></span> 333K</a></li>
      <li><a href=""><span class="ion-ios-person-outline"></span> 225M</a></li>
    </ul>
    <a href="" class="btn">Follow</a>
  </div>
</div>

<div class="window">
  <div class="overlay"></div>
  <div class="box header">
    <img src="http://via.placeholder.com/350x150" alt="" />
    <h2>Nera Parian Mohn</h2>
    <h4>Norway</h4>
  </div>
  <div class="box footer">
    <ul>
      <li><a href=""><span class="ion-ios-camera-outline"></span> 401</a></li>
      <li><a href=""><span class="ion-ios-heart-outline"></span> 333K</a></li>
      <li><a href=""><span class="ion-ios-person-outline"></span> 225M</a></li>
    </ul>
    <a href="" class="btn">Follow</a>
  </div>
</div>

<div class="window">
  <div class="overlay"></div>
  <div class="box header">
    <img src="http://via.placeholder.com/350x150" alt="" />
    <h2>Nera Parian Mohn</h2>
    <h4>Norway</h4>
  </div>
  <div class="box footer">
    <ul>
      <li><a href=""><span class="ion-ios-camera-outline"></span> 401</a></li>
      <li><a href=""><span class="ion-ios-heart-outline"></span> 333K</a></li>
      <li><a href=""><span class="ion-ios-person-outline"></span> 225M</a></li>
    </ul>
    <a href="" class="btn">Follow</a>
  </div>
</div>
<div class="window">
  <div class="overlay"></div>
  <div class="box header">
    <img src="http://via.placeholder.com/350x150" alt="" />
    <h2>Nera Parian Mohn</h2>
    <h4>Norway</h4>
  </div>
  <div class="box footer">
    <ul>
      <li><a href=""><span class="ion-ios-camera-outline"></span> 401</a></li>
      <li><a href=""><span class="ion-ios-heart-outline"></span> 333K</a></li>
      <li><a href=""><span class="ion-ios-person-outline"></span> 225M</a></li>
    </ul>
    <a href="" class="btn">Follow</a>
  </div>
</div>
</div>
&#13;
&#13;
&#13;

0 个答案:

没有答案