简体   繁体   English

我怎样才能在中间有一个文本并且文本是右对齐的

[英]how can i have a text in the middle and text that is right align

<p style="text-align: center;">Items <span style="padding-left: 50px;"><i id = 
"hi" class="arrow down"></i></span></p>

so I want the word item to be in the middle of and the image of arrow down to be in the right所以我希望词项在中间,向下箭头的图像在右边

在此处输入图像描述 Its not quiet clear what is your point eventually, so I made for you two ways that can help you to solve problems, as I understood your task, result on screenshot:最终不清楚你的观点是什么,所以我为你做了两种可以帮助你解决问题的方法,因为我理解你的任务,截图上的结果:

HTML: 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: 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%);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM