@sochi-russia

Почему блок с фотографиями (class="center") не по центру?

@import url(https://fonts.googleapis.com/css?family=Raleway);

*, *:before, *:after{
  margin: 0;
  padding: 0;
  -webkit-box-sizing: border-box;
  -moz-box-sizing:border-box;
  box-sizing: border-box;
}

body{
  background: #f9f9f9;
  font-size: 16px;
  font-family: 'Raleway', sans-serif;
}

.main-title{
  color: #2d2d2d;
  text-align: center;
  text-transform: capitalize;
  padding: 0.7em 0;
}

.cont{
    float: left;
  width: 240px;
border: 1px solid #9999991A;
margin: 5px;
}
@media screen and (max-width: 640px){
  .cont{
   width: 240px;
border: 1px solid #9999991A;
margin: 5px;
  }
}

@media screen and (min-width: 900px){
  .cont{
    width: 240px;
border: 1px solid #9999991A;
margin: 5px;
  }
}

.cont .title{
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 10px;
}

.content {
  position: relative;
  width: 90%;
  max-width: 400px;
  margin: auto;
  overflow: hidden;
}

.content .content-overlay {
  background: rgba(0,0,0,0.7);
  position: absolute;
  height: 99%;
  width: 100%;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  opacity: 0;
  -webkit-transition: all 0.4s ease-in-out 0s;
  -moz-transition: all 0.4s ease-in-out 0s;
  transition: all 0.4s ease-in-out 0s;
}

.content:hover .content-overlay{
  opacity: 1;
}

.content-image{
  width: 100%;
}

.content-details {
  position: absolute;
  text-align: center;
  padding-left: 1em;
  padding-right: 1em;
  width: 100%;
  top: 50%;
  left: 50%;
  opacity: 0;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  -webkit-transition: all 0.3s ease-in-out 0s;
  -moz-transition: all 0.3s ease-in-out 0s;
  transition: all 0.3s ease-in-out 0s;
}

.content:hover .content-details{
  top: 50%;
  left: 50%;
  opacity: 1;
}

.content-details h3{
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.15em;
  margin-bottom: 0.5em;
  text-transform: uppercase;
}

.content-details p{
  color: #fff;
  font-size: 0.8em;
}

.fadeIn-bottom{
  top: 80%;
}

.fadeIn-top{
  top: 20%;
}

.fadeIn-left{
  left: 20%;
}

.fadeIn-right{
  left: 80%;
}
.center{text-align:center;float:none;margine:0px auto; padding:0px;position:relative;width:100%;}


<div class="center">

  
<div class="cont">
  <h3 class="title">Адлер</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Адлер" title="авиабилеты Москва Адлер" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=AER&depart_date=2016-12-19&return_date=2016-12-30&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/AER.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">3365 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Бангкок</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Бангкок" title="авиабилеты Москва Бангкок" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=BKK&depart_date=2017-02-18&return_date=0001-01-01&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/BKK.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">15860 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Ереван</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Ереван" title="авиабилеты Москва Ереван" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=EVN&depart_date=2016-12-04&return_date=2017-01-01&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/EVN.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">7359 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Пхукет</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Пхукет" title="авиабилеты Москва Пхукет" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=HKT&depart_date=2016-11-30&return_date=0001-01-01&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/HKT.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">14409 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Краснодар</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Краснодар" title="авиабилеты Москва Краснодар" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=KRR&depart_date=2017-04-08&return_date=2017-04-11&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/KRR.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">3657 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Санкт-Петербург</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Санкт-Петербург" title="авиабилеты Москва Санкт-Петербург" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=LED&depart_date=2016-12-12&return_date=2016-12-18&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/LED.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">2729 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Махачкала</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Махачкала" title="авиабилеты Москва Махачкала" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=MCX&depart_date=2017-01-18&return_date=2017-01-26&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/MCX.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">3516 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Минеральные Воды</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Минеральные Воды" title="авиабилеты Москва Минеральные Воды" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=MRV&depart_date=2016-12-16&return_date=2016-12-16&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/MRV.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">3585 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Прага</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Прага" title="авиабилеты Москва Прага" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=PRG&depart_date=2017-03-15&return_date=2017-03-21&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/PRG.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">7664 руб.</p>
      </div>
    </a>
  </div>
</div>


<div class="cont">
  <h3 class="title">Симферополь</h3>
  <div class="content">
    <a rel="nofollow" alt="авиабилеты Москва Симферополь" title="авиабилеты Москва Симферополь" href="http://bilety.avia-avia.ru/searches/new?origin_iata=MOW&destination_iata=SIP&depart_date=2017-01-19&return_date=2017-01-22&adults=1&children=0&infants=0&trip_class=0&marker=87111&with_request=true">
      <div class="content-overlay"></div>
      <img class="content-image" src="//photo2.hotellook.com/static/cities/320x240/SIP.jpg"/>
      <div class="content-details fadeIn-bottom">
        <h3 class="content-title">Цена</h3>
        <p class="content-text">4054 руб.</p>
      </div>
    </a>
  </div>
</div>
</div>


Вот сам пример. avia-avia.ru/test2
  • Вопрос задан
  • 131 просмотр
Решения вопроса 1
iiiBird
@iiiBird Куратор тега CSS
Пока ты спишь - твой конкурент совершенствуется
во-первых у тебя ошибка в css .center {marginE:0px auto;}
ты не сможешь отцентрировать float:left элементы внутри блока. ну а если все же хочешь чтобы были отцентрированы, то верстай через inline-block; к примеру так:
https://jsfiddle.net/xsd5fveg/1/
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы