html - 如何设置按钮在图片边缘的位置?
问题描述
如何使用 CSS 将按钮定位在图片边缘?
我的代码
<div>
<button class="" aria-label="Eat cake">Btn</button>
<img class="pull-left" src="style.png" style="width: 160px; border: 1px solid #DEDEDC;"/>
</div>
问候,
解决方案
只是在这里给你一个例子,我只是将红色 btn 绝对定位到它的相对父级。
.blue-div{
margin: 10%;
position: relative;
width: 120px;
height: 120px;
background: blue;
}
.red-btn{
position: absolute;
top: -10px;
right: -10px;
background: red;
border: none;
outline: none;
border-radius: 50%;
padding: 8px 4px;
color: white;
}
<div class="blue-div">
<button class="red-btn">Btn</button>
</div>
推荐阅读
- vue.js - 在Vuex状态下清除对象属性的最佳方法是什么
- reactjs - react-axios 处理错误没有从服务器获取消息
- sqlite - SQLite3更新表在同一个查询中以一致的方式加减值
- r - 如何从回归中提取对数系数?R
- python - Python Json TypeError:字符串索引必须是整数错误
- asp.net - 我怎样才能让这个 API 调用只在 Student_ID = 我提供的 ID 时返回
- python - 如何将 json 列表值传递到 python 列表中?
- ios - icloud 驱动器文档未在设备之间立即同步
- tree - Erlang 二叉树函数
- python - 使用熊猫在另一列中查找具有相同条目的所有行条目