html - 需要让两个按钮在中心左右对齐几个像素
问题描述
需要让两个按钮在中心左右对齐几个像素我需要 div left 到中心左侧 1px。并有权成为它的 1 像素。
有什么想法吗?
.btn {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
color: black;
border: 2px solid black;
background-color: white;
width: 100px;
text-decoration: none;
}
.btn2 {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
color: white;
border: 2px solid white;
background-color: black;
width: 100px;
text-decoration: none;
}
.divleft {
margin: auto 0;
text-align: left;
}
.divright {
margin: auto 0;
text-align: right;
}
<div class="divleft"> <a href="en.wikipedia.org/wiki/Memento_mori" class="btn">Memento</a> </div>
<div class="divright"> <a href="discord.gg/j9Bh6mSjf2" class="btn2">Mori</a> </div>
解决方案
使用弹性盒:
.box {
display: flex;
width: 100%;
}
.left,
.right {
width: 100%;
}
.left {
text-align: right;
margin-right: 10px;
}
a {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
border: 2px solid black;
width: 100px;
text-decoration: none;
}
.btn {
color: black;
background-color: white;
}
.btn2 {
color: white;
background-color: black;
}
<div class="box">
<div class="left">
<a href="en.wikipedia.org/wiki/Memento_mori" class="btn">Memento</a>
</div>
<div class="right">
<a href="discord.gg/j9Bh6mSjf2" class="btn2">Mori</a>
</div>
</div>
代码笔: https ://codepen.io/manaskhandelwal1/pen/jOMgpbd
推荐阅读
- javascript - Express:发送到客户端后无法设置标头
- jquery - jQuery $(this) 正确隐藏/显示元素
- java - 控制器端点命名约定
- c# - MVC 错误 - 处理请求时发生未处理的异常。InvalidOperationException:模型通过
- cucumber - [Cucumber][Execution]如何将特定场景大纲作为套件中的最后一个脚本运行
- javascript - 如何在 excel Web 插件中获取当前 excel 文件的 base 64 字符串或字节数据?
- jestjs - SpyOn 的玩笑测试
- maven - 在 IntelliJ 运行配置中指定 maven 插件执行 ID
- python - 如何在 python 上正确安装 SVM-Light?
- c++ - QMediaPlayer::position() 返回零