如何仅在大屏幕上将下拉菜单的对齐方式更改为右对齐?
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Right-aligned menu
</button>
<div class="dropdown-menu dropdown-menu-right">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
在上面的代码中,dropdown-menu-right
应该只在大屏幕上应用。
最佳答案
您可以在 CSS
中使用 @media
@media (min-width: 998px) {
.dropdown-menu-right {
/* css here */
}
}
当然,998px
可以替换为适合您需要的任何值。
关于javascript - 如何更改大屏幕上的菜单对齐方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57134413/