0

我的桌面上有引导卡(bootstrap4),如下所示:

桌面

我的手机视图是这样的:

移动的

我的html代码是:

    <div class="card-deck">
    <div class="center card" style="width: 100%;">
        <a href="{{ path('qrcodemanual') }}"><img id="qrcheck" class="card-img-top" src="{{ asset('images/mobile_qr_code.png') }}"  alt="QR-Code"></a>
        <div class="card-body">
            <h5 class="card-title">{{ '/'|trans }}
                {% if qrcodeEnrollStatus == 1 %}
                    <span class="badge badge-success float-right">{{ '/'|trans }} </span>
                {% else %}
                    <span class="badge badge-secondary float-right">{{ '/'|trans }} </span>
                {% endif %}
            </h5>
            <p class="card-text">{{ 'userhome.qrcode.text'|trans }}</p>
            <a href="{{ path('qrcodemanual')}}" class="btn btn-primary">{{ '/'|trans }}</a>
        </div>
    </div>

    <div class="center card" style="width: 100%;">
        <img class="card-img-top" src="{{ asset('images/OTP.png') }}" alt="OTP">
        <div class="card-body">
            <h5 class="card-title">{{ '/'|trans }}
                {% if smsEnrollStatus != null %}
                    <span class="badge badge-success float-right">{{ '/'|trans }} </span>
                {% else %}
                    <span class="badge badge-secondary float-right">{{ '/'|trans }} </span>
                {% endif %}
            </h5>
            <p class="card-text">{{ '/'|trans }}</p>
            <a href="{{ path('smsmanual')}}" class="btn btn-primary">{{ '/'|trans }}</a>
        </div>
    </div>
</div>

<br>
<h5>Other options:</h5>
<br>

<div class="card-deck">
    <div class="center card" style="width: 100%;">
        <img class="card-img-top" src="{{ asset('images/OTP.png') }}" alt="OTP">
        <div class="card-body">
            <h5 class="card-title">{{ '/'|trans }}
                {% if emergencyEnrollStatus == 1 %}
                    <span class="badge badge-success float-right">{{ '/' |trans }} </span>
                {% else %}
                    <span class="badge badge-secondary float-right">{{ '/' |trans }} </span>
                {% endif %}
            </h5>
            <p class="card-text">{{ '/'|trans }}</p>
            <a href="{{ path('emergencypasswordmanual')}}" class="btn btn-primary">{{ '/'|trans }}</a>
        </div>
    </div>

    <div class="center card" style="width: 100%;">
        <img class="card-img-top" src="{{ asset('images/OTP.png') }}" alt="OTP">
        <div class="card-body">
            <h5 class="card-title">{{ '/'|trans }}</h5>
            <p class="card-text">{{ '/'|trans }}</p><br>
            <a href="/" class="btn btn-primary">{{ '/'|trans }}</a>
        </div>
    </div>
</div>

我希望桌面视图中的卡片更小。如何在保持移动视图不变的同时做到这一点?

现在,当我更改宽度时,移动视图也会受到影响。

4

1 回答 1

0

您可以使用 @media 来控制一些 CSS 用于桌面显示,如下所示:

  <style>
      @media  only screen and (min-width : 768px) {
          .card {
            display: block !important;
            width: 25rem !important;
            flex:none !important;
          }
      }
  </style>
于 2021-01-22T04:11:01.120 回答