javascript - 我怎样才能在中间有一个文本并且文本是右对齐的
问题描述
<p style="text-align: center;">Items <span style="padding-left: 50px;"><i id =
"hi" class="arrow down"></i></span></p>
所以我希望词项在中间,向下箭头的图像在右边
解决方案
最终不清楚你的观点是什么,所以我为你做了两种可以帮助你解决问题的方法,因为我理解你的任务,截图结果:
HTML:
<div class="item">
<span>
Items
</span>
<i id = "hi" class="arrow down">---></i>
</div>
<p class="item2">
<span>
Items
</span>
<i id = "hi" class="arrow down">---></i>
</p>
CSS:
.item {
position: relative;
background: black;
color: #fff;
width: 200px;
height: 200px;
margin: 20px auto;
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
}
.item .arrow {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
}
.item2 {
position: relative;
background: black;
color: #fff;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
}
.item2 .arrow {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
}
推荐阅读
- regex - 如何正确链接 Perl 替换
- c# - 如何延迟模拟httpMessageHandler?
- javascript - 如何在后端 Vb.net 上调用 Javascript 函数
- ruby - 为什么Ruby除法四舍五入?
- json - Python 解析 JSON 响应的 JSON 列表
- python - 将数据点加载到二维数组中
- visual-studio-code - 为 VSCode WSL 终端设置 umask
- azure-data-factory - Azure 数据工厂 - Azure 数据湖的增量加载
- javascript - 在 HTML 中间附加一个图表
- r - 如何使用 R 中插入符号包中的训练函数对分类预测变量进行逐步多元回归?