html - 按钮html中的边框
问题描述
我正在尝试在按钮中添加边框,我尝试创建 2 个 div 然后执行display: inline-block
但它不起作用,这是我的代码:
`#vid {
position: absolute;
width: 95px;
height: 60px;
background-color: #ffff;
border: #ffff;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
display: inline-block;
}
#h5-vid {
border-radius: 25px;
background: #ffff;
border-color: black;
display: inline-block;
}
<button id="vid"><p>Videos</p><div id="h5-vid"><h5 id="h5-text-vid">New!</h5></button></div>`
这就是我想要得到的:
这就是我得到的:
解决方案
将两个带有文本的元素放在按钮内:
<button id="vid">
<p>Videos</p>
<h5 id="h5-text-vid">NEW</h5>
</button>
使用display: flex;
justify 和 align center 按钮,然后简单地使用添加边框到h5
元素border: solid 1px black;
这是一个工作片段:
#vid {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
width: 95px;
height: 60px;
background-color: #ffff;
border: none;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
}
#h5-text-vid {
border: solid 1px black;
border-radius: 25px;
padding: 3px;
font-size: 6pt;
font-weight: 800;
}
body {
/* Just for demo */
background-color: gray;
}
<button id="vid">
<p>Videos</p>
<h5 id="h5-text-vid">NEW</h5>
</button>
推荐阅读
- javascript - 只有objectID保存在mongodb中另一个模型的数组中
- c# - 编译时间类型检查
- scala - 如何使用参与者系统对 if 表达式进行建模?
- python - 在 urwid 中创建后退按钮
- html - 输入“日期”字段不会与 HTML 中的其他字段对齐
- rabbitmq - Spring Actuator RabbitMQ - Prometheus 未显示消息计数
- .net - .Net Core 代码构建问题
- overlay - HERE 地图:在 MapSettingsControl 中动态添加图层
- python - 在 python Tkinter 条目中键入和删除某些内容后保留占位符?
- php - 为什么这个 php 代码给了我一个空白屏幕?