tesicg
tesicg

Reputation: 4053

How to setup Bootstrap to work as expected?

The code looks as following:

<template lang="pug">
b-container
  b-row
    b-col
      h1
        strong LICOTA® — ПРОФЕССИОНАЛЬНЫЙ ИНСТРУМЕНТ ВЫСШЕГО КЛАССА ДЛЯ АВТОСЕРВИСОВ И ПРОМЫШЛЕННЫХ ПРЕДПРИЯТИЙ
  b-row.mt-1
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-card(img-src='https://licota.ru/home_banners/info-item-1.png' img-alt='Image' img-top tag='article' class='info-block__card--no-border h-100')
        b-card-text Имеет TUV сертификат ISO 9001:2008. Соответствует требованиям GS, CE, EAC и превышает нормы DIN и ГОСТ
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-card(img-src='https://licota.ru/home_banners/info-item-2.png' img-alt='Image' img-top tag='article' class='info-block__card--no-border h-100')
        b-card-text Один из ведущих производителей инструмента в мире с трехуровневым контролем качества
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-card(img-src='https://licota.ru/home_banners/info-item-3.png' img-alt='Image' img-top tag='article' class='info-block__card--no-border h-100')
        b-card-text Инструмент адаптирован к российским условиям и имеет пожизненную гарантию на брак изготовителя
  b-row.mt-1
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-card(img-src='https://licota.ru/home_banners/info-item-4.png' img-alt='Image' img-top tag='article' class='info-block__card--no-border h-100')
        b-card-text Наши клиенты из автомобильного сегмента, которые выбрали Licota®
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-card(img-src='https://licota.ru/home_banners/info-item-5.png' img-alt='Image' img-top tag='article' class='info-block__card--no-border h-100')
        b-card-text Эти промышленные предприятия уверенно работают с Licota®
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-card(img-src='https://licota.ru/home_banners/info-item-6.png' img-alt='Image' img-top tag='article' class='info-block__card--no-border h-100')
        b-card-text Дилеры Licota® по всей России, от Калининграда до Камчатки
  b-row.mt-1
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-button(class='info-block__button' block size='lg') О ПРОИЗВОДИТЕЛЕ
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-button(class='info-block__middle-button' block size='lg') КАТАЛОГ ТОВАРОВ
    b-col(class='col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column')
      b-button(class='info-block__button' block size='lg') ГДЕ КУПИТЬ?
</template>

<script lang="ts">
import Vue from 'vue'
import { Data } from 'types/header/nav/catalog'
import testData from '../data/testData.json'

export default Vue.extend({
  data: (): Data => ({
    catalog: [],
  }),
  mounted(): void {
    this.catalog = testData.catalog
  },
})
</script>

<style lang="sass">
.info-block
  font-size: 16px
  text-align: center
.info-block__column
  padding: 10px
.info-block__card--no-border
  border: none
.info-block__button
  background-color: #eee
  background-image: -webkit-linear-gradient(bottom, #ccc 0%, #eee 100%)
  border: 1px solid #cccccc
  color: black
  font-size: 18px
  font-weight: bold
  line-height: 2
  text-shadow: 0.5px 0.866px 0 white
.info-block__middle-button
  background-color: #007dfa
  background-image: -webkit-linear-gradient(bottom, #00468c 0%, #007dfa 100%)
  border: 1px solid rgb(0, 70, 140)
  color: white
  font-size: 18px
  font-weight: bold
  line-height: 2
  text-shadow: 0.5px 0.866px 0 rgb(0, 30, 60)
</style>

As you can see, it's Vue.js application where we use "pug" template engine and BootstrapVue component library. I'm trying to make the app responsive using b-col with Bootstrap's col-xs-, col-sm-, and so on.

The main page with different screen's width looks as following:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

I'm not sure why the screenshots with "It's not OK" look as they are.

How can I fix it?

UPDATE:

This is code that works fine except for screen's width <576px.

<template lang="pug">
  b-container
    b-row
      b-col
        h1
          strong LICOTA® — ПРОФЕССИОНАЛЬНЫЙ ИНСТРУМЕНТ ВЫСШЕГО КЛАССА ДЛЯ АВТОСЕРВИСОВ И ПРОМЫШЛЕННЫХ ПРЕДПРИЯТИЙ
    b-row.mt-1
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-card(img-src='https://licota.ru/home_banners/info-item-1.png' img-alt='Image' img-top tag='article').info-block__card--no-border.h-100
          b-card-text Имеет TUV сертификат ISO 9001:2008. Соответствует требованиям GS, CE, EAC и превышает нормы DIN и ГОСТ
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-card(img-src='https://licota.ru/home_banners/info-item-2.png' img-alt='Image' img-top tag='article').info-block__card--no-border.h-100
          b-card-text Один из ведущих производителей инструмента в мире с трехуровневым контролем качества
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-card(img-src='https://licota.ru/home_banners/info-item-3.png' img-alt='Image' img-top tag='article').info-block__card--no-border.h-100
          b-card-text Инструмент адаптирован к российским условиям и имеет пожизненную гарантию на брак изготовителя
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-card(img-src='https://licota.ru/home_banners/info-item-4.png' img-alt='Image' img-top tag='article').info-block__card--no-border.h-100
          b-card-text Наши клиенты из автомобильного сегмента, которые выбрали Licota®
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-card(img-src='https://licota.ru/home_banners/info-item-5.png' img-alt='Image' img-top tag='article').info-block__card--no-border.h-100
          b-card-text Эти промышленные предприятия уверенно работают с Licota®
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-card(img-src='https://licota.ru/home_banners/info-item-6.png' img-alt='Image' img-top tag='article').info-block__card--no-border.h-100
          b-card-text Дилеры Licota® по всей России, от Калининграда до Камчатки
    b-row.mt-1
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-button.btn.btn-lg.btn-block.info-block__button О ПРОИЗВОДИТЕЛЕ
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-button.btn.btn-lg.btn-block.info-block__middle-button КАТАЛОГ ТОВАРОВ
      b-col.col-xs-12.col-sm-12.col-md-6.col-lg-4.col-xl-4.info-block__column
        b-button.btn.btn-lg.btn-block.info-block__button ГДЕ КУПИТЬ?
</template>

The compiled HTML code (BootstrapVue) looks as following:

<b-container>
    <b-row>
        <b-col>
            <h1><strong>LICOTA® — ПРОФЕССИОНАЛЬНЫЙ ИНСТРУМЕНТ ВЫСШЕГО КЛАССА ДЛЯ АВТОСЕРВИСОВ И ПРОМЫШЛЕННЫХ ПРЕДПРИЯТИЙ</strong></h1>
        </b-col>
    </b-row>
    <b-row class="mt-1">
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-card class="info-block__card--no-border h-100" img-src="https://licota.ru/home_banners/info-item-1.png" img-alt="Image" img-top="img-top" tag="article">
                <b-card-text>Имеет TUV сертификат ISO 9001:2008. Соответствует требованиям GS, CE, EAC и превышает нормы DIN и ГОСТ</b-card-text>
            </b-card>
        </b-col>
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-card class="info-block__card--no-border h-100" img-src="https://licota.ru/home_banners/info-item-2.png" img-alt="Image" img-top="img-top" tag="article">
                <b-card-text>Один из ведущих производителей инструмента в мире с трехуровневым контролем качества</b-card-text>
            </b-card>
        </b-col>
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-card class="info-block__card--no-border h-100" img-src="https://licota.ru/home_banners/info-item-3.png" img-alt="Image" img-top="img-top" tag="article">
                <b-card-text>Инструмент адаптирован к российским условиям и имеет пожизненную гарантию на брак изготовителя</b-card-text>
            </b-card>
        </b-col>
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-card class="info-block__card--no-border h-100" img-src="https://licota.ru/home_banners/info-item-4.png" img-alt="Image" img-top="img-top" tag="article">
                <b-card-text>Наши клиенты из автомобильного сегмента, которые выбрали Licota®</b-card-text>
            </b-card>
        </b-col>
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-card class="info-block__card--no-border h-100" img-src="https://licota.ru/home_banners/info-item-5.png" img-alt="Image" img-top="img-top" tag="article">
                <b-card-text>Эти промышленные предприятия уверенно работают с Licota®</b-card-text>
            </b-card>
        </b-col>
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-card class="info-block__card--no-border h-100" img-src="https://licota.ru/home_banners/info-item-6.png" img-alt="Image" img-top="img-top" tag="article">
                <b-card-text>Дилеры Licota® по всей России, от Калининграда до Камчатки</b-card-text>
            </b-card>
        </b-col>
    </b-row>
    <b-row class="mt-1">
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-button class="btn btn-lg btn-block info-block__button">О ПРОИЗВОДИТЕЛЕ</b-button>
        </b-col>
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-button class="btn btn-lg btn-block info-block__middle-button">КАТАЛОГ ТОВАРОВ</b-button>
        </b-col>
        <b-col class="col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
            <b-button class="btn btn-lg btn-block info-block__button">ГДЕ КУПИТЬ?</b-button>
        </b-col>
    </b-row>
</b-container>

Upvotes: 0

Views: 116

Answers (1)

terrymorse
terrymorse

Reputation: 7086

You have broken up the 6 cards into two rows, so when the screen is too narrow for 3 columns of cards, the third card is moved to a new line, all by itself.

The simplest fix: put all 6 cards into a single row.

Here is the HTML version of your markup, having placed all the cards into a single row:

.info-block {
      font-size: 16px;
      text-align: center;
    }

    .info-block__column {
      padding: 10px;
    }

    .info-block__card--no-border {
      border: none;
    }

    .info-block__button {
      background-color: #eee;
      background-image: -webkit-linear-gradient(bottom, #ccc 0%, #eee 100%);
      border: 1px solid #cccccc;
      color: black;
      font-size: 18px;
      font-weight: bold;
      line-height: 2;
      text-shadow: 0.5px 0.866px 0 white;
    }

    .info-block__middle-button {
      background-color: #007dfa;
      background-image: -webkit-linear-gradient(bottom, #00468c 0%, #007dfa 100%);
      border: 1px solid rgb(0, 70, 140);
      color: white;
      font-size: 18px;
      font-weight: bold;
      line-height: 2;
      text-shadow: 0.5px 0.866px 0 rgb(0, 30, 60);
    }
<!-- bootstrap 4.6.0 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.css">

<body class="p-4" style="background-color: #d0d0d0">

  <div class="container">

    <div class="row">
      <div class="col">
        <h1><strong>LICOTA® — ПРОФЕССИОНАЛЬНЫЙ ИНСТРУМЕНТ ВЫСШЕГО КЛАССА ДЛЯ
        АВТОСЕРВИСОВ И ПРОМЫШЛЕННЫХ ПРЕДПРИЯТИЙ</strong></h1>
      </div>
    </div>

    <div class="row mt-1">
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <div class="card info-block__card--no-border h-100">
          <img src="https://licota.ru/home_banners/info-item-1.png" class="card-img-top">
          <div class="card-body">
            <p class="card-text">Имеет TUV сертификат ISO 9001:2008. Соответствует требованиям GS, CE, EAC и превышает нормы DIN и ГОСТ</p>
          </div>
        </div>
      </div>
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <div class="card info-block__card--no-border h-100">
          <img src="https://licota.ru/home_banners/info-item-2.png" class="card-img-top">
          <div class="card-body">
            <p class="card-text">Один из ведущих производителей инструмента в мире с трехуровневым контролем качества</p>
          </div>
        </div>
      </div>
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <div class="card info-block__card--no-border h-100">
          <img src="https://licota.ru/home_banners/info-item-3.png" class="card-img-top">
          <div class="card-body">
            <p class="card-text">Инструмент адаптирован к российским условиям и имеет пожизненную гарантию на брак изготовителя</p>
          </div>
        </div>
      </div>
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <div class="card info-block__card--no-border h-100">
          <img src="https://licota.ru/home_banners/info-item-4.png" class="card-img-top">
          <div class="card-body">
            <p class="card-text">Наши клиенты из автомобильного сегмента, которые выбрали Licota®</p>
          </div>
        </div>
      </div>
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <div class="card info-block__card--no-border h-100">
          <img src="https://licota.ru/home_banners/info-item-5.png" class="card-img-top">
          <div class="card-body">
            <p class="card-text">Эти промышленные предприятия уверенно работают с Licota®</p>
          </div>
        </div>
      </div>
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <div class="card info-block__card--no-border h-100">
          <img src="https://licota.ru/home_banners/info-item-6.png" class="card-img-top">
          <div class="card-body">
            <p class="card-text">Дилеры Licota® по всей России, от Калининграда до Камчатки</p>
          </div>
        </div>
      </div>
    </div>

    <div class="row mt-1">
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <button class="btn btn-lg info-block__button">ПРОИЗВОДИТЕЛЕ</button>
      </div>
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <button class="btn btn-lg info-block__middle-button">КАТАЛОГ ТОВАРОВ</button>
      </div>
      <div class="col col-xs-12 col-sm-12 col-md-6 col-lg-4 col-xl-4 info-block__column">
        <button class="btn btn-lg info-block__button">ГДЕ КУПИТЬ?</button>
      </div>
    </div>
  </div>
</body>

Screenshots:

screenshot 1204 px wide window

screenshot 1004 px wide window

screenshot 800 px wide window

screenshot 585 px wide window

Upvotes: 2

Related Questions