Оформление ленты новостей в виде сетки и списка

Разработка Оформление ленты новостей в виде сетки и списка

Нет прав для скачивания
Оформление ленты новостей в виде сетки и списка.
Так как код HTML весьма большой мы его пропустим его можно будет посмотреть в файле примере во вложении, пишем стиль:
Less:
@white: #fff;
@lighter-gray: #eceff1;
@light-gray: #ddd;
@primary: #0068b3;
@background-gray: #5c676f;
@gray: #868686;
@dim-gray: #676767;
@dark-gray: #333;
@darker-gray: #212121;
@black: #0a0a0a;

@red: #d03d3d;
@green: #41c341;


// style

html {
  font-size: 100%;
}

body {
  background: @background-gray;
  font-family: 'Open Sans', Arial, sans-serif;
  font-size: 18px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 400;
}

.container {
  background: @lighter-gray;
  width: 100%;
  height: auto;
}


.header {
  min-height: 160px;
  padding: 3rem;
  background: @gray;

  img.logo {

  }
}

.key-icons {
  padding-left: 15px;

  .fa-caret-up {
    transform: rotate(45deg);
    color: @red;
    line-height: 0;
    font-size: 50px;
  }

  .fa-bookmark {
    color: gold;
    margin-left: 2rem;
    font-size: 30px;
    margin-right: 4px;
  }
}

.badge {
  padding: 8px 15px;
  background: @lighter-gray;
  border: @light-gray;
  margin-bottom: 5px;
}

.dark-bg {
  background: @black;
}

.footer {
  min-height: 40px;
  padding: 8rem;

  p.footer-copy {
    font-size: 0.75rem;
    color: @dim-gray;
    text-align: center;
  }
}

.view-mode.col-6 {
  transition: all 0.2s ease-in-out;
}

.view-mode.col-4 {
  transition: all 0.2s ease-in-out;
}

.view-mode.col-12 {

  .article-card {

    .bookmarked {
      left: 110px;
      top: 12px;
    }

    .card-img-top {
      display: none;
    }

    .card-body {
      p.card-text {
        font-family: 'Open Sans', sans-serif;
        font-weight: normal;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }
    }
  }
}


.fa-search {
  color: @light-gray !important;

  &:hover {
    color: @primary !important;
  }
}

//CARDS

.card {
  margin-bottom: 1rem;

  &.sidebar-card {
    display: block;

    .card-header {
      background: @primary;

      h3.card-title {
        color: @white;
        margin: 0;
        font-weight: 500;
        font-family: 'Montserrat', sans-serif;
      }
    }

    .card-footer {

      .btn {
        border-radius: 0 0 3px 3px;
      }
    }
  }

  &.search-card {



    .card-header {

      h3.card-title {
        margin: 0;
        font-weight: 500;
      }
    }

    .card-body {

      .btn {
        padding: 5px 10px;
        border-color: @light-gray;
        font-size: 13px;

        &:hover {
          background: lighten(@light-gray,6%);
          border-color: @gray;
        }
      }
    }
  }


  &.article-card {
    border-radius: 4px;

    img.card-img-top {
      border-radius: 4px 4px 0 0;
    }

    .card-body {
      background: @white;

      h4.card-title {
        font-size: 1.4rem;
        font-weight: 600;
        color: @dark-gray;
        margin-top: 1rem;
      }


      p.card-text {
        font-family: 'Open Sans', sans-serif;
        font-weight: normal;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
    }

    .card-footer {
      background: @white;
      padding: 0;
      border-radius: 0 0 4px 4px;

      .btn {
        border-radius: 0 0 4px 4px;
        font-family: 'Montserrat', sans-serif;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.04rem;
        transition: all 0.2s ease-in-out;

        .fa {
          position: absolute;
          opacity: 0;
          right: 10%;
          transition: all 0.2s ease-in-out;
        }

        &:hover {
          transition: all 0.2s ease-in-out;
          letter-spacing: 2px;
          .fa {
            opacity: 1;
            right: 2%;
            display: inline-block;
            transition: all 0.2s ease-in-out;
          }
        }
      }
    }
  }
}



.toggle {
  padding: 0 15px 15px;
  text-align: right;
  display: block;
}

@media all and (max-width: 767px) {
  .toggle {
    display: none;
  }

  #sidebar-searchform {
    display: none;
  }

  h4.article-main-title {
    font-size: 20px;
    font-weight: 700;
  }

  p.article-excerpt {
    display: none;
  }
}



.toggle a {
  display: inline-block;
  color: #ccc;
  font-size: 24px;
  text-decoration: none !important;
  vertical-align: middle;
}

.toggle a.on {
  color: #333;
}

.toggle a i.fa-bars {
  transform: translateY(-1px);
}

p.toggle-row {
  margin-bottom: 0;
}


//SWITCHES

.checkbox-switch {
  position: relative;
  margin-bottom: 25px;
}

.checkbox-switch input {
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 0%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
  filter: alpha(opacity=0);
}

.checkbox-switch input+span {
  cursor: pointer;
  user-select: none;
  padding-left: 3.5rem;
  color: #999;
  font-size: 18px;
  line-height: 1.4238;
  display: inline-block;
}

h3.panel-title {
  font-family: 'Arial', sans-serif;
  font-weight: 700;
  font-size: 24px;
}

@media all and (min-width: 992px) {
  .checkbox-switch input+span {
    cursor: pointer;
    user-select: none;
    padding-left: 3.5rem;
    color: #999;
    font-size: 18px;
    line-height: 1.4238;
  }
}

i {
  font-style: normal;
}

.adjust-right {
  margin-right: 7px;
}

.adjust-left {
  margin-left: 7px;
}




// SIDEBAR SEARCH
.search-container{
  width: 100%;
  display: block;
}

input#search-bar{
  margin: 0 auto;
  width: 100%;
  height: 45px;
  padding: 0 20px;
  border: 1px solid #0068b3;
  border-radius: 4px;
  outline: none;
}

input#search-bar:focus{
  border: 1px solid #008ABF;
  transition: 0.35s ease;
  color: #008ABF;
}

input#search-bar:focus::-webkit-input-placeholder {
  transition: opacity 0.45s ease;
  opacity: 0;
}

input#search-bar:focus::-moz-placeholder {
  transition: opacity 0.45s ease;
  opacity: 0;
}

input#search-bar:focus:-ms-placeholder {
  transition: opacity 0.45s ease;
  opacity: 0;
}

.search-icon {
  position: relative;
  float: right;
  top: -33px;
  right: 15px;
}


.checkbox-switch input+span:before {
  position: absolute;
  left: 0;
  display: inline-block;
  content: "";
  border-radius: 50px;
  height: 24px;
  width: 44px;
  background: rgba(100, 100, 100, 0.2);
  box-shadow: none;
  transition: background 0.2s ease-out;
}

.checkbox-switch input+span:after {
  width: 25px;
  height: 25px;
  position: absolute;
  left: 0px;
  top: 0;
  display: block;
  background: #ffffff;
  transition: margin-left 0.1s ease-in-out;
  text-align: center;
  font-weight: bold;
  content: "";
  border: solid transparent 2px;
  background-clip: padding-box;
  border-radius: 50px;
}

.checkbox-switch input:checked+span {
  color: #000;
  background: #f7f7f7;
  padding-right: 15px;
  border-radius: 50px;
  font-weight: 700;
}

.checkbox-switch input:checked+span:after {
  margin-left: 20px;
  content: "";
  border: solid transparent 2px;
  background-clip: padding-box;
  -webkit-animation: popIn ease-in 0.3s normal;
  animation: popIn ease-in 0.3s normal;
}

.checkbox-switch input:checked+span:before {
  transition: background 0.2s ease-in;
  background: #0068b3;
}

.checkbox-switch input:not(:checked)+span:after {
  -webkit-animation: popOut ease-in 0.3s normal;
  animation: popOut ease-in 0.3s normal;
}

h3.filter-heading {
  color: @dim-gray;
  margin: 50px 0 20px;
  font-size: 17px;
  padding-bottom: 10px;
  border-bottom: 2px solid #ccc;
}

@media all and (min-width: 992px) {
  h3.filter-heading {
    font-size: 22px;
    border-bottom: 2px solid #ccc;
    font-weight: 500;
  }
}



// MAIN SEARCH FILTERS


.filter-wrapper i.fa {
  color: #aaa;
  opacity: 1;
  font-size: inherit;
  line-height: 1.4238;
}

.filter-wrapper i.fa:hover {
  color: #bf0000;
}

.filter-wrapper .btn-default {
  border-color: #ccc;
  font-family: 'Arial', sans-serif;
}


.filter-wrapper .alert {
  margin: 0 10px 10px 0;
  display: inline-block;
}

@media all and (min-width: 992px) {
  .filter-wrapper .alert {
    margin: 0 10px 0 0;
    display: inline-block;
  }
}

h3.search-filters {
  text-transform: none;
  color: #333;
  margin: 0 0 15px;
  font-size: 19px;
}



// NEW INDICATOR
.unread {
  width: 10em;
  height: 6em;
  position: absolute;
  right: 0;

  &:before,
  &:after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-color: transparent;
    border-style: solid;
  }

  &:after {
    border-radius: 0 4px 0 0;
    border-width: 1.35em;
    border-right-color: @red;
    border-top-color: @red;
  }
}

.bookmarked {
  position: absolute;
  top: 10px;
  left: 10px;

  &:before {
    content: '\f02e';
    font-family: 'FontAwesome';
    font-size: 2rem;
    color: gold;
    position: absolute;
    top: 0;
    left: 10px;
  }
}

// MEDIA QUERIES (GROUPED)

@media (min-width: 400px) {
  .container {
    max-width: 100% !important;
  }
}

@media (min-width: 1600px) {
  .container {
    max-width: 1440px !important;
  }
}

@media (min-width: 1920px) {
  .container {
    max-width: 1680px !important;
  }
}

@media (min-width: 2560px) {
  .container {
    max-width: 1920px !important;
  }
}
Пишем js:
JavaScript:
//grid/list toggle for thumbnails
var $bigButton = jQuery('a.view.big');
var $gridButton = jQuery('a.view.grid');
var $listButton = jQuery('a.view.list');
var $items = jQuery('div.view-mode');

$listButton.on('click', function() {
  $gridButton.removeClass('on');
  $listButton.addClass('on');
  $items.removeClass('col-4').addClass('col-12');
});

$listButton.on('click', function() {
  $bigButton.removeClass('on');
  $listButton.addClass('on');
  $items.removeClass('col-6').addClass('col-12');
});

$gridButton.on('click', function() {
  $listButton.removeClass('on');
  $gridButton.addClass('on');
  $items.removeClass('col-12').addClass('col-4');
});

$gridButton.on('click', function() {
  $bigButton.removeClass('on');
  $gridButton.addClass('on');
  $items.removeClass('col-6').addClass('col-4');
});

$bigButton.on('click', function() {
  $listButton.removeClass('on');
  $gridButton.addClass('on');
  $items.removeClass('col-12').addClass('col-6');
});

$bigButton.on('click', function() {
  $gridButton.removeClass('on');
  $bigButton.addClass('on');
  $items.removeClass('col-4').addClass('col-6');
});


var selectedBox = null;

$(document).ready(function() {
  $(".radio-feed").click(function() {
    selectedBox = this.id;
    $(".radio-feed").each(function() {
      if ( this.id == selectedBox )
      {
        this.checked = true;
      }
      else
      {
        this.checked = false;
      }
    });
  });

  $(".radio-filter").click(function() {
    selectedBox = this.id;
    $(".radio-filter").each(function() {
      if ( this.id == selectedBox )
      {
        this.checked = true;
      }
      else
      {
        this.checked = false;
      };
    });
  });

  $(".radio-publications").click(function() {
    selectedBox = this.id;
    $(".radio-publications").each(function() {
      if ( this.id == selectedBox )
      {
        this.checked = true;
      }
      else
      {
        this.checked = false;
      };
    });
  });

  $(".radio-topics").click(function() {
    selectedBox = this.id;
    $(".radio-topics").each(function() {
      if ( this.id == selectedBox )
      {
        this.checked = true;
      }
      else
      {
        this.checked = false;
      };
    });
  });


  $(".radio-categories").click(function() {
    selectedBox = this.id;
    $(".radio-categories").each(function() {
      if ( this.id == selectedBox )
      {
        this.checked = true;
      }
      else
      {
        this.checked = false;
      };
    });
  });

});


var checkboxes = document.getElementsByTagName('input');

for (var i=0; i<checkboxes.length; i++)  {
  if (checkboxes[i].type == 'checkbox')   {
    checkboxes[i].checked = false;
  }
};

$(function () {
  $('[data-toggle="tooltip"]').tooltip()
});


//sidebar offcanvas
$(function () {
  $('[data-toggle=offcanvas]').click(function () {
    if ($('.sidebar-offcanvas').css('background-color') == 'rgb(255, 255, 255)') {
      $('.list-group-item').attr('tabindex', '-1');
    } else {
      $('.list-group-item').attr('tabindex', '');
    }
    $('.row-offcanvas').toggleClass('active');

  });
});
Смотрим результут:
dr30.gif
Автор
baltun
Скачиваний
0
Просмотры
582
Первый выпуск
Обновление
Рейтинг
0.00 звёзд Оценок: 0

Ещё ресурсы от baltun

Похожие ресурсы
Назад
Верх Низ