如何在移动设备和平板电脑上切换按钮位置?

huangapple go评论71阅读模式
英文:

How to switch button position on mobiles and tables?

问题

当在较小的设备上显示时,按钮占据整个宽度,这是预期的行为。然而,我想要的是,当这种情况发生时,Next 按钮显示在 Back 按钮的上方。这个是否可能?

英文:

I have the following snippet:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css&quot; integrity=&quot;sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm&quot; crossorigin=&quot;anonymous&quot;&gt;

&lt;div class=&quot;container&quot;&gt;
  &lt;div class=&quot;row&quot;&gt;
    &lt;div class=&quot;col-12 pt-2 d-flex flex-column flex-md-row justify-content-md-end&quot;&gt;
      &lt;button type=&quot;button&quot; class=&quot;btn btn-secondary mb-2 mb-md-0 mr-md-2&quot;&gt;Back&lt;/button&gt;
      &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot;&gt;Next&lt;/button&gt;          
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

<!-- end snippet -->

When displayed on smaller devices, the buttons occupy the whole width. This is as expected.

However, I would like that when this happens, the Next button is displayed above the Back button.

Is this possible?

答案1

得分: 1

请尝试以下代码:

@media screen and (max-width: 767px){
  .btn-secondary{
    order: 1;
   }
  .btn-primary{
     margin-bottom: 0.5rem !important;
   }
}
英文:

Please try this code

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

@media screen and (max-width: 767px){
  .btn-secondary{
		order: 1;
   }
  .btn-primary{
	   margin-bottom: 0.5rem !important;
   }
}

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年6月26日 22:23:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557608.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定