css - 当一个按钮被包装到表单中时,如何将按钮显示为内联/块元素?
问题描述
当其中一个按钮包装在表单中时,如何在小屏幕上将两个按钮显示为块元素以及在大屏幕上显示内联元素?
我有两个按钮,一个只是本地链接,另一个是(由我的同事)包裹在 from. 现在我在较小的屏幕上显示页面时遇到问题。表单内的按钮将不再显示为块元素。
结果应如下所示:
小屏幕:
| 按钮1 |
| 按钮2 |
大屏幕:
| 按钮1 | | 按钮2 |
到目前为止我的代码:
https://www.bootply.com/CETPAyWp2K
(调整屏幕宽度看效果)
解决方案
使用w-100到 lg 屏幕使用button[type="submit"]
:media-query
@media (min-width: 992px) {
form {
display: inline;
}
button[type="submit"]{
width: auto!important;
}
}
见小提琴:https ://jsfiddle.net/m9n4dgw7/5/
form { display: block;
}
@media (min-width: 992px) {
form {
display: inline;
}
button[type="submit"]{
width: auto!important;
}
}
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col" class="text-right">Action</th>
</tr>
</thead>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<tbody>
<tr>
<td class="content_name">Samplecol 1</td>
<td class="text-right">
<a class="btn btn-warning btn-sm btn-edit d-block d-lg-inline mb-1 mb-lg-0" href="#">Edit</a>
<form action="http://localhost:10777/Delete/3aac236e" method="post">
<button type="submit" class="btn btn-danger btn-sm w-100 d-block d-lg-inline mb-1 mb-lg-0">Delete</button>
</form>
</td>
</tr>
<tr>
<td class="content_name">Samplecol 2</td>
<td class="text-right">
<a class="btn btn-warning btn-sm btn-edit d-block d-lg-inline mb-1 mb-lg-0" href="#">Edit</a>
<form action="http://localhost:10777/Delete/d81de31b" method="post">
<button type="submit" class="btn btn-danger btn-sm w-100 d-block d-lg-inline mb-1 mb-lg-0">Delete</button>
</form>
</td>
</tr>
</tbody>
</table>
推荐阅读
- android - Android Volley - JsonArrayRequest 返回空对象
- python - 用beautifulsoup gettext 抓取多个东西以获取roop 代码
- eclipse - 如何在 Eclipse 的“远程系统”中为用户操作添加键绑定?
- javascript - Chrome.extensions :打开选项卡 > 执行脚本 > 关闭选项卡
- sql - 基于 MIN 标志聚合行
- jakarta-mail - 如果以 =?UTF-8?B? 开头,邮件主题未解码?邮箱 1.5.6
- github - 致命:“pack.deltacachesize”的错误数字配置值“=”:无效单位
- oracle - IIB: INSERT INTO Oracle Database "¿"(倒问号)和汉字
- java - 如何从 selenium java 中的 getLocation 获取精确的 y 坐标?
- android - 如何在android中检测已经与设备连接的OTG电缆?